New submission from Adam Ernst <adamjer...@gmail.com>:

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.

----------
components: Library (Lib)
messages: 130362
nosy: Adam.Ernst
priority: normal
severity: normal
status: open
title: logging FileHandler.close should acquire its lock before closing stream
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to