diff --git a/src/allmydata/watchdog/_watchdog_541.py b/src/allmydata/watchdog/_watchdog_541.py new file mode 100644 index 000000000..87686ce6d --- /dev/null +++ b/src/allmydata/watchdog/_watchdog_541.py @@ -0,0 +1,16 @@ +""" +Hotfix for https://github.com/gorakhargosh/watchdog/issues/541 +""" + +from watchdog.observers.fsevents import FSEventsEmitter + +# The class object has already been bundled up in the default arguments to +# FSEventsObserver.__init__. So mutate the class object (instead of replacing +# it with a safer version). +original_on_thread_stop = FSEventsEmitter.on_thread_stop +def safe_on_thread_stop(self): + if self.is_alive(): + return original_on_thread_stop(self) + +def patch(): + FSEventsEmitter.on_thread_stop = safe_on_thread_stop diff --git a/src/allmydata/watchdog/inotify.py b/src/allmydata/watchdog/inotify.py index 5db35d9dd..4b717aae6 100644 --- a/src/allmydata/watchdog/inotify.py +++ b/src/allmydata/watchdog/inotify.py @@ -53,6 +53,9 @@ from ..util.eliotutil import ( validateInstanceOf, ) +import ._watchdog_541 +_watchdog_541.patch() + NOT_STARTED = "NOT_STARTED" STARTED = "STARTED" STOPPING = "STOPPING"