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 rcronk
Recipients Frans, lowell87, mramahi77, neyro, rcronk, vinay.sajip
Date 2009-06-08.16:34:14
SpamBayes Score 0.0
Marked as misclassified No
Message-id <>
I have a small script that reproduces the problem.  I couldn't 
reproduce it until I added some os.system() calls in the threads that 
were logging.  Here's the output using python 2.6.1:

Traceback (most recent call last):
  File "C:\Python26\lib\logging\", line 74, in emit
    if self.shouldRollover(record):
  File "C:\Python26\lib\logging\", line 146, in 
shouldRollover, 2)  #due to non-posix-compliant Windows feature
ValueError: I/O operation on closed file

Here is the script - let me know if I'm doing things incorrectly:

import os, threading, logging, logging.handlers

class LoggerThread(threading.Thread):
    def __init__(self, numLoops):
	self.numLoops = numLoops

    def run(self):
	for x in range(0, self.numLoops):
	    os.system('del blah.txt')
	    logging.debug('This is log message ' + str(x) + ' from ' + + ' and I think this should be a little longer, so I\'ll add 
some more data here because perhaps the size of the individual log 
message is a factor.  Who knows for sure until this simple test fails.')

if __name__=="__main__":
    logSize = 2048
    numberOfLogs = 10

    files = logging.handlers.RotatingFileHandler('logthred.log', 'a', 
logSize, numberOfLogs)
    console = logging.StreamHandler()

    # set a format
    fileFormatter = logging.Formatter('%(asctime)s %(levelname)-8s %
(thread)-4s %(message)s')
    consoleFormatter = logging.Formatter('%(asctime)s %(levelname)-8s %
(thread)-4s %(message)s')

    # tell the handler to use this format

    # add the handlers to the root logger

    numThreads = 10
    numLoops = 100

    # Create and execute threads
    for x in range(0, numThreads):
Date User Action Args
2009-06-08 16:34:16rcronksetrecipients: + rcronk, vinay.sajip, mramahi77, lowell87, neyro, Frans
2009-06-08 16:34:16rcronksetmessageid: <>
2009-06-08 16:34:15rcronklinkissue4749 messages
2009-06-08 16:34:14rcronkcreate