python-daemon and PID files
ben+python at benfinney.id.au
Mon Mar 6 05:50:06 EST 2017
Ethan Furman <ethan at stoneleaf.us> writes:
> On 03/04/2017 09:09 PM, Ian Pilcher wrote:
> > Is it possible to get python-daemon to create "systemd style" PID
> > file?
Short answer: No, that's the job of whatever ‘pidfile’ object you
Medium answer: Yes, by implementing that behaviour in the object you
choose to present as the ‘pidfile’ option. The ‘python-lockfile’ library
is suggested as one implementation, but there are of course others.
Longer answer: Because ‘python-daemon’ is deliberately agnostic about
what the ‘pidfile’ object does, you can give it any behaviour you like.
The only thing the ‘DaemonContext.pidfile’ option is expected to do is
be a context manager; what happens when that context manager is entered
or exited is up to you.
> I know my library, pandaemonium , will allow you to write the pid
> file complete with the daemon's PID, and I would be very surprised if
> Ben's python-daemon did not also allow that.
It certainly allows it: put whatever behaviour your application needs in
the context manager's methods.
More about writing a context manager can be found at the documentation
\ “If we listen only to those who are like us, we will squander |
`\ the great opportunity before us: To live together peacefully in |
_o__) a world of unresolved differences.” —David Weinberger |
More information about the Python-list