os.rename [Errno 31] Too many links
Thomas Guettler
hv at tbz-pariv.de
Wed Mar 10 11:08:44 EST 2010
Richard wrote:
> 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?
If you are on linux you can have a look at the open file descriptors of
a running process like this:
ls -l /proc/PID/fd/
But I guess it is a limitation of your filesystem. What do you use?
I once had this problem with ext2. It has a low limit for
subdirectories.
With xfs the limits are much greater.
Thomas
--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
More information about the Python-list
mailing list