summaryrefslogtreecommitdiff
path: root/python2/pyinotify.py
diff options
context:
space:
mode:
Diffstat (limited to 'python2/pyinotify.py')
-rwxr-xr-xpython2/pyinotify.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index 82592a8..f03de1b 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -1543,18 +1543,30 @@ class AsyncNotifier(asyncore.file_dispatcher, Notifier):
class TornadoAsyncNotifier(Notifier):
"""
Tornado ioloop adapter.
+
"""
- def __init__(self, watch_manager, ioloop, default_proc_fun=None,
- read_freq=0, threshold=0, timeout=None, channel_map=None):
+ def __init__(self, watch_manager, ioloop, callback=None,
+ default_proc_fun=None, read_freq=0, threshold=0, timeout=None,
+ channel_map=None):
"""
- See example transient_file_tornado.py
+ Note that if later you must call ioloop.close() be sure to let the
+ default parameter to all_fds=False.
+
+ See example transient_file_tornado.py for an example using this
+ notifier.
@param ioloop: Tornado's IO loop.
@type ioloop: tornado.ioloop.IOLoop instance.
+ @param callback: Functor called at the end of each call to handle_read
+ (IOLoop's read handler). Expects to receive the
+ notifier object (self) as single parameter.
+ @type callback: callable object or function
"""
+ self.io_loop = ioloop
+ self.handle_read_callback = callback
Notifier.__init__(self, watch_manager, default_proc_fun, read_freq,
threshold, timeout)
- ioloop.add_handler(os.dup(self._fd), self.handle_read, ioloop.READ)
+ ioloop.add_handler(self._fd, self.handle_read, ioloop.READ)
def handle_read(self, *args, **kwargs):
"""
@@ -1563,6 +1575,8 @@ class TornadoAsyncNotifier(Notifier):
"""
self.read_events()
self.process_events()
+ if self.handle_read_callback is not None:
+ self.handle_read_callback(self)
class Watch:
@@ -1621,6 +1635,7 @@ class Watch:
class ExcludeFilter:
"""
ExcludeFilter is an exclusion filter.
+
"""
def __init__(self, arg_lst):
"""