release function raises exception when file handler is already closed

Bug #1377579 reported by Nir Arad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Concurrent Log Handler for Python
New
Undecided
Unassigned

Bug Description

In ConcurrentRotatingFileHandler.release() you're calling:
self.stream.flush()

If the file handler is already closed, a ValueError is raised ("I/O operation on closed file").
You can wrap the code is a try block like so to avoid such problem:

    def release(self):
        """ Release file and thread locks. Flush stream and take care of closing
        stream in 'degraded' mode. """
        try:
            self.stream.flush()
            if self._rotateFailed:
                self.stream.close()
        except ValueError:
            pass # I/O operation on closed file
        finally:
            try:
                unlock(self.stream_lock)
            finally:
                # release thread lock
                logging.Handler.release(self)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.