summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2014-11-26 03:04:54 -0500
committerAvery Pennarun <apenwarr@gmail.com>2014-11-26 03:06:33 -0500
commit5b8699693956fec9693330613592aa5f87892511 (patch)
treee6bf6b3c3d7f18d4ed2939af23a20bc1555c3a8e
parenta51277db95321eae90656e1fbc4ef8b11584735f (diff)
downloadpyinotify-5b8699693956fec9693330613592aa5f87892511.tar.gz
Allow TornadoAsyncNotifier.stop() to clean up all hanging refs.
Without this, the TornadoAsyncNotifier and thus WatchManager instances are never freed, because tornado is still holding a refernce to the handler.
-rwxr-xr-xpython2/pyinotify.py5
-rwxr-xr-xpython3/pyinotify.py5
2 files changed, 10 insertions, 0 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index 7733337..707c8e3 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -1447,6 +1447,7 @@ class Notifier:
"""
self._pollobj.unregister(self._fd)
os.close(self._fd)
+ self._sys_proc_fun = None
class ThreadedNotifier(threading.Thread, Notifier):
@@ -1593,6 +1594,10 @@ class TornadoAsyncNotifier(Notifier):
threshold, timeout)
ioloop.add_handler(self._fd, self.handle_read, ioloop.READ)
+ def stop(self):
+ self.io_loop.remove_handler(self._fd)
+ Notifier.stop(self)
+
def handle_read(self, *args, **kwargs):
"""
See comment in AsyncNotifier.
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index 57c3549..f604385 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -1437,6 +1437,7 @@ class Notifier:
"""
self._pollobj.unregister(self._fd)
os.close(self._fd)
+ self._sys_proc_fun = None
class ThreadedNotifier(threading.Thread, Notifier):
@@ -1583,6 +1584,10 @@ class TornadoAsyncNotifier(Notifier):
threshold, timeout)
ioloop.add_handler(self._fd, self.handle_read, ioloop.READ)
+ def stop(self):
+ self.io_loop.remove_handler(self._fd)
+ Notifier.stop(self)
+
def handle_read(self, *args, **kwargs):
"""
See comment in AsyncNotifier.