summaryrefslogtreecommitdiff
path: root/python2/examples/transient_file_tornado.py
blob: 554f3cd97674884021272f2960713e0b81b73649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()