This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Adam.Ernst
Recipients Adam.Ernst
Date 2011-03-08.19:54:33
SpamBayes Score 1.0202061e-11
Marked as misclassified No
Message-id <1299614074.11.0.136259749977.issue11444@psf.upfronthosting.co.za>
In-reply-to
Content
This is my first report, apologies if I missed any tracker etiquette.

The logging module registers shutdown() to run via atexit. shutdown() calls flush() and close() on each handler.

However if a FileHandler is writing to a file while shutdown() is executing, an IOError will be raised as the file is being closed while written to. (This can happen if you use daemon threads, which can still be running while exiting.)


Traceback (most recent call last):
  File "/usr/local/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/local/lib/python2.7/logging/__init__.py", line 1616, in shutdown
    h.close()
  File "/usr/local/lib/python2.7/logging/__init__.py", line 898, in close
    self.stream.close()
IOError: close() called during concurrent operation on the same file object.


I'm not familiar with the internals of logging, but it seems that FileHandler should call self.acquire()/self.release() around its close and flush operations. Otherwise a daemon thread might be emitting a record while closing the handler.
History
Date User Action Args
2011-03-08 19:54:34Adam.Ernstsetrecipients: + Adam.Ernst
2011-03-08 19:54:34Adam.Ernstsetmessageid: <1299614074.11.0.136259749977.issue11444@psf.upfronthosting.co.za>
2011-03-08 19:54:33Adam.Ernstlinkissue11444 messages
2011-03-08 19:54:33Adam.Ernstcreate