summaryrefslogtreecommitdiff
path: root/python3
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2012-10-04 00:45:11 +0200
committerSebastien Martini <seb@dbzteam.org>2012-10-04 00:45:11 +0200
commit75f63f3f63ed1105b5cad98e1121dc55e5043cba (patch)
tree10369427d4bd97720144d843839f5d5d71f12daf /python3
parent8599f88bf9c4217861ebac681362b96d98c2c000 (diff)
downloadpyinotify-75f63f3f63ed1105b5cad98e1121dc55e5043cba.tar.gz
Ported TornadoAsyncNotifier to Python3.
Assuming Tornado works the same way under Python3... I must say I don't use Tornado myself I didn't test it.
Diffstat (limited to 'python3')
-rwxr-xr-xpython3/pyinotify.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index a826efb..6c52708 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -1535,6 +1535,33 @@ class AsyncNotifier(asyncore.file_dispatcher, Notifier):
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):
+ """
+ See example transient_file_tornado.py
+
+ @param ioloop: Tornado's IO loop.
+ @type ioloop: tornado.ioloop.IOLoop instance.
+
+ """
+ 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):
+ """
+ See comment in AsyncNotifier.
+
+ """
+ self.read_events()
+ self.process_events()
+
+
class Watch:
"""
Represent a watch, i.e. a file or directory being watched.