summaryrefslogtreecommitdiff
path: root/python2/examples/loop.py
blob: 48c81ad22dd84f66a2f212b4466f09f6ca2f669d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Example: loops monitoring events forever.
#
import pyinotify

# Instanciate a new WatchManager (will be used to store watches).
wm = pyinotify.WatchManager()
# Associate this WatchManager with a Notifier (will be used to report and
# process events).
notifier = pyinotify.Notifier(wm)
# Add a new watch on /tmp for ALL_EVENTS.
wm.add_watch('/tmp', pyinotify.ALL_EVENTS)
# Loop forever and handle events.
notifier.loop()