bug with os.rename in 2.4.1?

MRAB google at mrabarnett.plus.com
Tue Apr 28 19:45:23 CEST 2009


t123 wrote:
> I was wondering if anyone has seen this problem before?
> 
> I have a job that runs hourly.  Part of the processing is to rename a
> file using os.rename.  The file name is the same every hour.
> Sometimes the os.rename fails and the file does not get renamed.  It
> only happens occasionally.  Most of the time it works just fine.
> 
> Appreciate any ideas.
> 
This can happen if an antivirus checker, or Windows indexing service
(assuming you're using Windows), or some such background task, is
accessing the file at the time. It's a good idea to wait a short time
and then retry, perhaps more than once, before giving up. Just write a
short function to do this.



More information about the Python-list mailing list