summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2014-07-10 20:14:14 +0200
committerSebastien Martini <seb@dbzteam.org>2014-07-10 20:14:14 +0200
commitd2b201ea12e60ec9daee083ee886d1537e751a4b (patch)
treed704e56556c8696bf7aa3196a69beb23c7575faa
parent12cf58b82bd81624fd8d87239697474cadf73c3a (diff)
downloadpyinotify-d2b201ea12e60ec9daee083ee886d1537e751a4b.tar.gz
Improve example daemon.py.
Closes #77
-rw-r--r--python2/examples/daemon.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/python2/examples/daemon.py b/python2/examples/daemon.py
index e1e9ac1..c0246f7 100644
--- a/python2/examples/daemon.py
+++ b/python2/examples/daemon.py
@@ -35,14 +35,18 @@ on_loop_func = functools.partial(on_loop, counter=Counter())
# Notifier instance spawns a new process when daemonize is set to True. This
# child process' PID is written to /tmp/pyinotify.pid (it also automatically
-# deletes it when it exits normally). If no custom pid_file is provided it
-# would write it more traditionally under /var/run/. Note that in both cases
-# the caller must ensure the pid file doesn't exist when this method is called
-# othewise it will raise an exception. /tmp/stdout.txt is used as stdout
-# stream thus traces of events will be written in it. callback is the above
-# function and will be called after each event loop.
+# deletes it when it exits normally). Note that this tmp location is just for
+# the sake of the example to avoid requiring administrative rights in order
+# to run this example. But by default if no explicit pid_file parameter is
+# provided it will default to its more traditional location under /var/run/.
+# Note that in both cases the caller must ensure the pid file doesn't exist
+# before this method is called otherwise it will raise an exception.
+# /tmp/pyinotify.log is used as log file to dump received events. Likewise
+# in your real code choose a more appropriate location for instance under
+# /var/log (this file may contain sensible data). Finally, callback is the
+# above function and will be called after each event loop.
try:
notifier.loop(daemonize=True, callback=on_loop_func,
- pid_file='/tmp/pyinotify.pid', stdout='/tmp/stdout.txt')
+ pid_file='/tmp/pyinotify.pid', stdout='/tmp/pyinotify.log')
except pyinotify.NotifierError, err:
print >> sys.stderr, err