diff options
author | Sebastien Martini <seb@dbzteam.org> | 2010-09-15 01:08:07 +0200 |
---|---|---|
committer | Sebastien Martini <seb@dbzteam.org> | 2010-09-15 01:08:07 +0200 |
commit | 909f985842fcae8a45d9591017112186e68a723d (patch) | |
tree | 7ef6a19285efd6100e88190a7fa6595922dfc5f9 /python2/examples | |
parent | 155e2f5d0dfeff210198856b2b03d53d8e810c52 (diff) | |
download | pyinotify-909f985842fcae8a45d9591017112186e68a723d.tar.gz |
Optionally no pid file is written (pid_file=False) when notifier.loop
with daemonize=True is called.
Diffstat (limited to 'python2/examples')
-rw-r--r-- | python2/examples/daemon.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/python2/examples/daemon.py b/python2/examples/daemon.py index aeb5249..e1e9ac1 100644 --- a/python2/examples/daemon.py +++ b/python2/examples/daemon.py @@ -36,8 +36,13 @@ 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/. /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. -notifier.loop(daemonize=True, callback=on_loop_func, - pid_file='/tmp/pyinotify.pid', stdout='/tmp/stdout.txt') +# 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. +try: + notifier.loop(daemonize=True, callback=on_loop_func, + pid_file='/tmp/pyinotify.pid', stdout='/tmp/stdout.txt') +except pyinotify.NotifierError, err: + print >> sys.stderr, err |