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 <1368698382.27.0.729614629625.issue17981@psf.upfronthosting.co.za>
In-reply-to
Content
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.addHandler(handler)
logger.setLevel(logging.DEBUG)

logger.info("Hello, ")

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

Output in syslog after running the above:

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