Author vinay.sajip
Recipients Julien.Palard, joshpurvis, vinay.sajip
Date 2013-05-16.09:59:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The python-daemon documentation states, about files_preserve:

"Elements of the list are file descriptors (as returned by a file object's `fileno()` method) or Python `file` objects. Each specifies a file that is not to be closed during daemon start."

Notice that file objects are just a convenience - filenos() can be passed. The following, slightly modified script works as expected:

import logging
import logging.handlers
import daemon

logger = logging.getLogger('twitterCounter')
handler = logging.handlers.SysLogHandler(address='/dev/log')
logger.setLevel(logging.DEBUG)"Hello, ")

with daemon.DaemonContext(files_preserve=[handler.socket.fileno()]):"world!")

Output in syslog after running the above:

May 16 10:58:42 eta-oneiric64 Hello, 
May 16 10:58:42 eta-oneiric64 world!
Date User Action Args
2013-05-16 09:59:42vinay.sajipsetrecipients: + vinay.sajip, Julien.Palard, joshpurvis
2013-05-16 09:59:42vinay.sajipsetmessageid: <>
2013-05-16 09:59:42vinay.sajiplinkissue17981 messages
2013-05-16 09:59:42vinay.sajipcreate