How do I implement a simple cross platform Python daemon?

Nick Bolton picture Nick Bolton · Feb 13, 2010 · Viewed 8.1k times · Source

I would like to have my Python program run in the background as a daemon, on either Windows or Unix. I see that the python-daemon package is for Unix only; is there an alternative for cross platform? If possible, I would like to keep the code as simple as I can.

Answer

Alex Martelli picture Alex Martelli · Feb 13, 2010

In Windows it's called a "service" and you could implement it pretty easily e.g. with the win32serviceutil module, part of pywin32. Unfortunately the two "mental models" -- service vs daemon -- are very different in detail, even though they serve similar purposes, and I know of no Python facade that tries to unify them into a single framework.