Message189346
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! |
|
Date |
User |
Action |
Args |
2013-05-16 09:59:42 | vinay.sajip | set | recipients:
+ vinay.sajip, Julien.Palard, joshpurvis |
2013-05-16 09:59:42 | vinay.sajip | set | messageid: <1368698382.27.0.729614629625.issue17981@psf.upfronthosting.co.za> |
2013-05-16 09:59:42 | vinay.sajip | link | issue17981 messages |
2013-05-16 09:59:42 | vinay.sajip | create | |
|