[pypy-issue] Issue #2302: strange behavior with python-daemon and TimedRotatingFileHandler (pypy/pypy)
gzivdo
issues-reply at bitbucket.org
Fri May 20 08:17:00 EDT 2016
New issue 2302: strange behavior with python-daemon and TimedRotatingFileHandler
https://bitbucket.org/pypy/pypy/issues/2302/strange-behavior-with-python-daemon-and
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:
{code}
Traceback (most recent call last):
File "./123.py", line 83, in <module>
main()
File "./123.py", line 43, in main
pass
IOError: [Errno 9] Bad file descriptor: '<fdopen>'
{code}
Sample code to reproduce:
{code}
#!/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()
{code}
It stop working because of "from logging.handlers import TimedRotatingFileHandle", if i comment it - it works fine.
More information about the pypy-issue
mailing list