Re: File Closing Problem in 2.3 and 2.4, Not in 2.5
- From: rweth <rweth@xxxxxxxxx>
- Date: Sat, 06 Jan 2007 12:44:06 -0800
Martin v. Löwis wrote:
Carroll, Barry schrieb:What I want to know is:
* has anyone else encountered a problem like this, * how was the
problem corrected, * can the fix be retro-fitted to 2.5 and 2.4?
From your description, I suspect an error in your code. Your description
indicates that you don't expect to have more than five files open
simultaneously. Yet, the error message "Too many open files" occurs when
you open many more files (in the order of hundreds of files).
It is very unlikely that there is a bug in Python where it would fail to
close a file when .close() is explicitly invoked on it (as your
description suggests that you do), so if you get that error message, it
can only mean that you fail to close some files.
Notice that you may have other files open, as well, and that those also
count towards the limit.
As a debugging utility, you can use Sysinternal's process explorer.
Make the program halt (not exit) when the exception occurs (e.g. by
having it sleep(1) in a loop), then view all open handles in the
process explorer (check the menu if it doesn't display them initially).
Regards,
Martin
I agree with Martin .. this code to close is solid.
Make certain you are really closing the files when you think you should. I am pretty sure you are not. Look at the code that closes the files closely. Put a print statement in the block that is supposed to close the files (may bee even a raw_input("closing file" + afile) statement).
My guess is that you won't see the print statements trigger when you though they should .. they may be out of "the loop" you thought that they were in.
.
- References:
- File Closing Problem in 2.3 and 2.4, Not in 2.5
- From: Carroll, Barry
- Re: File Closing Problem in 2.3 and 2.4, Not in 2.5
- From: "Martin v. Löwis"
- File Closing Problem in 2.3 and 2.4, Not in 2.5
- Prev by Date: Re: nntplib downloads content with extra linebreaks
- Next by Date: Recommended way to force a thread context switch?
- Previous by thread: Re: File Closing Problem in 2.3 and 2.4, Not in 2.5
- Next by thread: Re: File Closing Problem in 2.3 and 2.4, Not in 2.5
- Index(es):
Relevant Pages
|