Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Why does this not work? #223

Open
mkornacker opened this issue Apr 3, 2023 · 2 comments
Open

[Question] Why does this not work? #223

mkornacker opened this issue Apr 3, 2023 · 2 comments

Comments

@mkornacker
Copy link

(I'm running this on Ubuntu.)
I was expecting the following code snippet to print a single file addition, but path_generator doesn't return anything. I might be missing something obvious...

import watchfiles
import threading
import uuid
stop_event = threading.Event()
path_generator = watchfiles.watch('./wftest', stop_event=stop_event)
path = f'./wftest/{uuid.uuid4().hex[:8]}.txt'
with open(path, 'w') as f:
    f.write('hello')
stop_event.set()
for change_set in path_generator:
    print(change_set)
@samuelcolvin
Copy link
Owner

Don't know for sure.

You might need to wait a little time for the changes to propagate!?

@kevin-bates
Copy link

I suspect this is because stop_event.set() is getting in the way. If you comment that out, you'll see your Change.added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants