Searching on Google reveals x2 code snippets. The first result is to this code recipe which has a lot of documentation and explanation, along with some useful discussion und
Probably not a direct answer to the question, but systemd can be used to run your application as a daemon. Here is an example:
[Unit]
Description=Python daemon
After=syslog.target
After=network.target
[Service]
Type=simple
User=
Group=
ExecStart=/usr/bin/python /script.py
# Give the script some time to startup
TimeoutSec=300
[Install]
WantedBy=multi-user.target
I prefer this method because a lot of the work is done for you, and then your daemon script behaves similarly to the rest of your system.
-Orby