summaryrefslogtreecommitdiff
path: root/python2/examples/transient_file_tornado.py
diff options
context:
space:
mode:
authorLE0N <flyguy.by@gmail.com>2012-10-03 22:45:19 +0300
committerLE0N <flyguy.by@gmail.com>2012-10-03 22:45:19 +0300
commit0bd8d6fa0ccf7faebcde813a1f6d60c7fca482d6 (patch)
treeb415ffc475ce4fdbf035e54a29efbaf5bde39c1d /python2/examples/transient_file_tornado.py
parent66c395418d52e1506678e077dfa51a062c7f3735 (diff)
downloadpyinotify-0bd8d6fa0ccf7faebcde813a1f6d60c7fca482d6.tar.gz
Add tornado ioloop support
Diffstat (limited to 'python2/examples/transient_file_tornado.py')
-rw-r--r--python2/examples/transient_file_tornado.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python2/examples/transient_file_tornado.py b/python2/examples/transient_file_tornado.py
new file mode 100644
index 0000000..554f3cd
--- /dev/null
+++ b/python2/examples/transient_file_tornado.py
@@ -0,0 +1,19 @@
+import pyinotify
+from tornado.ioloop import IOLoop
+
+wm = pyinotify.WatchManager() # Watch Manager
+mask = pyinotify.IN_MODIFY
+
+class EventHandler(pyinotify.ProcessEvent):
+ def process_IN_MODIFY(self, event):
+ # We have explicitely registered for this kind of event.
+ print '\t', event.pathname, ' -> written'
+ def process_default(self, event):
+ print event
+
+ioloop = IOLoop.instance()
+notifier = pyinotify.TornadoAsyncNotifier(wm, ioloop)
+#daemon.pids['nginx']
+wdd = wm.watch_transient_file('/tmp/test_file', pyinotify.IN_MODIFY, EventHandler)
+
+ioloop.start() \ No newline at end of file