Need help in configuration for TimedRotatingFileHandler

Vinay Sajip vinay_sajip at
Tue Aug 11 12:23:00 CEST 2009

On Aug 10, 3:52 pm, Dave Angel <da... at> wrote:
> Lokesh Maremalla wrote:
> > Traceback (most recent call last):
> >   File "c:\Python25\lib\logging\", line 74, in emit
> >     self.doRollover()
> >   File "c:\Python25\lib\logging\", line 274, in doRollover
> >     os.rename(self.baseFilename, dfn)
> > WindowsError: [Error 32] The process cannot access the file because it is
> > being used by another process
> Generally speaking, this error on os.rename() will occur if you haven't
> properly closed the file first, and if I recall correctly, Unix would
> have permitted a rename on an open file.  You're on Windows.  However, I
> don't know how that works with theloggingpackage.  If the program has
> terminated, and you run it a second time on the following day (or after
> changing the system time), then I'd expect no trouble.  But I'm guessing
> your program is still running, and you just want to change fromlogging
> to yesterday's file tologgingto today's file.
> If I had to guess, I'd say that you have two instances of the logger
> running, and the second one is still holding the handle open.  But
> that's just a wild guess.

It's certainly possible that there are two instances of the handler,
which would cause this problem. Other things which might cause this
problem are the file handle inherited by a child process, an anti-
virus scanner having the file open for scanning (anti-virus scanners
often scan files which have just been written, like log files) and
indexing software such as Google Desktop or Windows' own indexing

I would advise using sysinternals tools such as FileMon and Handle to
see what's holding the file open.


Vinay Sajip

More information about the Python-list mailing list