os.rename [Errno 31] Too many links

Richard richardbp at gmail.com
Wed Mar 10 09:29:03 EST 2010


I want to atomically write to a file so have been using temporary
files and renaming:

temp = tempfile.NamedTemporaryFile(delete=False)
temp.file.write(data)
temp.file.close()
os.rename(temp.name, output_file)

This worked but after 39567 files os.rename raises an OSError: [Errno
31] Too many links

I can still create files in this directory so I doubt it is a platform
limitation.
Can you tell what is wrong? Am I not freeing the temporary file
resources properly?

thanks,
Richard





More information about the Python-list mailing list