Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 654
    • Issues 654
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #2302

Closed
Open
Created May 20, 2016 by Bitbucket Importer@bitbucket_importerMaintainer

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
Assignee
Assign to
Time tracking