diff options
author | Sebastien Martini <seb@dbzteam.org> | 2012-10-04 12:18:04 +0200 |
---|---|---|
committer | Sebastien Martini <seb@dbzteam.org> | 2012-10-04 12:18:04 +0200 |
commit | aea39987fa5f3efaad15c2fa4fe2597996393327 (patch) | |
tree | 0ebde30839328b39722cc274f01f08c1bd7ac8b1 /python3 | |
parent | 75f63f3f63ed1105b5cad98e1121dc55e5043cba (diff) | |
download | pyinotify-aea39987fa5f3efaad15c2fa4fe2597996393327.tar.gz |
Improved Tornado's notifier.
Diffstat (limited to 'python3')
-rwxr-xr-x | python3/pyinotify.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/python3/pyinotify.py b/python3/pyinotify.py index 6c52708..76ef043 100755 --- a/python3/pyinotify.py +++ b/python3/pyinotify.py @@ -1540,18 +1540,28 @@ 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): """ @@ -1560,6 +1570,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: |