From 5b8699693956fec9693330613592aa5f87892511 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 26 Nov 2014 03:04:54 -0500 Subject: 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. --- python2/pyinotify.py | 5 +++++ python3/pyinotify.py | 5 +++++ 2 files changed, 10 insertions(+) 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. -- cgit v1.2.1