diff options
author | LE0N <flyguy.by@gmail.com> | 2012-10-03 22:45:19 +0300 |
---|---|---|
committer | LE0N <flyguy.by@gmail.com> | 2012-10-03 22:45:19 +0300 |
commit | 0bd8d6fa0ccf7faebcde813a1f6d60c7fca482d6 (patch) | |
tree | b415ffc475ce4fdbf035e54a29efbaf5bde39c1d /python2/pyinotify.py | |
parent | 66c395418d52e1506678e077dfa51a062c7f3735 (diff) | |
download | pyinotify-0bd8d6fa0ccf7faebcde813a1f6d60c7fca482d6.tar.gz |
Add tornado ioloop support
Diffstat (limited to 'python2/pyinotify.py')
-rwxr-xr-x | python2/pyinotify.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py index cd9fc94..6ca990d 100755 --- a/python2/pyinotify.py +++ b/python2/pyinotify.py @@ -1539,6 +1539,25 @@ class AsyncNotifier(asyncore.file_dispatcher, Notifier): self.read_events() self.process_events() +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): + Notifier.__init__(self, watch_manager, default_proc_fun, read_freq, + threshold, timeout) + ioloop.add_handler(os.dup(self._fd), self.handle_read, ioloop.READ) + def handle_read(self,*args,**kwargs): + """ + When asyncore tells us we can read from the fd, we proceed processing + events. This method can be overridden for handling a notification + differently. + + """ + self.read_events() + self.process_events() + class Watch: """ |