blob: 16be53304b037aad2a20d1f2ff4841d6b34363e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import pyinotify
import asyncio
def handle_read_callback(notifier):
"""
Just stop receiving IO read events after the first
iteration (unrealistic example).
"""
print('handle_read callback')
notifier.loop.stop()
wm = pyinotify.WatchManager()
loop = asyncio.get_event_loop()
notifier = pyinotify.AsyncioNotifier(wm, loop,
callback=handle_read_callback)
wm.add_watch('/tmp', pyinotify.ALL_EVENTS)
loop.run_forever()
notifier.stop()
|