strange behavior with python-daemon and TimedRotatingFileHandler
Created originally on Bitbucket by gzivdo
This works fine with old pypy 2.x and with python 2.7, but not works with pypy 5.1.2 I am getting error:
#!python
Traceback (most recent call last):
File "./111.py", line 30, in <module>
main()
File "./111.py", line 12, in main
pass
IOError: [Errno 9] Bad file descriptor: '<fdopen>'
Sample code to reproduce:
#!python
#!/usr/local/pypy-centos7-x64/bin/pypy
import daemon, signal, time, logging, os, sys, lockfile
from logging.handlers import TimedRotatingFileHandler
log = 'foo.log'
def main():
while True:
with os.popen('/usr/bin/lzcat some_test_file.lzma') as f:
print f
for line in f:
pass
logFormatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(log)
#fh = TimedRotatingFileHandler(log, when="d", interval=1, backupCount=10)
fh.setFormatter(logFormatter)
logger.addHandler(fh)
context = daemon.DaemonContext(
files_preserve = [
fh.stream,
],
stdout = fh.stream, #no formatting
stderr = fh.stream,
)
with context:
main()
It stop working because of "from logging.handlers import TimedRotatingFileHandle", if i comment it - it works fine.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information