watchfiles
watchfiles copied to clipboard
[Question] Why does this not work?
(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)
Don't know for sure.
You might need to wait a little time for the changes to propagate!?
I suspect this is because stop_event.set()
is getting in the way. If you comment that out, you'll see your Change.added
.