You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classReloader:
defstart(self):
fromthreadingimportThreadself.thread=Thread(target=self.run)
self.thread.start()
defstop(self):
self._event.set()
assertself._event.is_set()
delself._event# remove this line can solve the issue tooself.thread.join()
@cached_propertydef_event(self):
returnEvent()
defrun(self):
fromwatchfilesimportwatch# move this line to the top of the file to solve the issuefor_inwatch(".", stop_event=self._event):
...
reloader=Reloader()
reloader.start()
reloader.stop()
print("done")
In the snippet above, both threading.Event and asyncio.Event will fail.
Watchfiles Output
"done" will never show
Operating System & Architecture
Windows-11-10.0.26100-SP0
10.0.26100
Environment
the normal way
Python & Watchfiles Version
python: 3.13.2 (main, Feb 5 2025, 19:16:35) [MSC v.1942 64 bit (AMD64)], watchfiles: 1.0.4
Rust & Cargo Version
No response
The text was updated successfully, but these errors were encountered:
Description
If
watchfiles
is imported inside a separated thread andstop_event
is deleted after being set, it will be weirdly reset toFalse
.I can't clearly explain this, so I upload a minimal reproduction repo here:
https://github.com/CNSeniorious000/watchfiles-repro
Example Code
In the snippet above, both
threading.Event
andasyncio.Event
will fail.Watchfiles Output
Operating System & Architecture
Windows-11-10.0.26100-SP0
10.0.26100
Environment
the normal way
Python & Watchfiles Version
python: 3.13.2 (main, Feb 5 2025, 19:16:35) [MSC v.1942 64 bit (AMD64)], watchfiles: 1.0.4
Rust & Cargo Version
No response
The text was updated successfully, but these errors were encountered: