This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Built-in open function fail. Too many file open
Type: Stage:
Components: None Versions: Python 2.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: alexteo21, georg.brandl, loewis
Priority: normal Keywords:

Created on 2007-06-07 10:28 by alexteo21, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg32240 - (view) Author: Alex (alexteo21) Date: 2007-06-07 10:28
Hi,

I have created a cron script using python.
Every hour it will batch process certain files

e.g.

t=open(filename,'rb')
data=t.read()
#processing data...
t.close()

The script is working fine on the day of execution.
It is able to process the files.  However, when the next day comes, the processing fail!!

Traceback (most recent call last):
  File "./alexCopy.py", line 459, in processRequestModule
    sanityTestSteps(reqId,model)
  File "./alexCopy.py", line 699, in sanityTestSteps
    t = open(filename, 'rb')
IOError: [Errno 24] Too many open files:

I have explicitly closed the file.
Please help.

Thanks,
Alex
msg32241 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-06-07 13:08
Please do *not* open another bug when your first one was closed!

If you think closing it was not correct, reopen the first one.
In this case, however, I referred you to comp.lang.python, so
*please* post the issue (and your script) there.
msg32242 - (view) Author: Alex (alexteo21) Date: 2007-06-07 14:22
Additional info
I am running the script on solaris.
If I have a similar script in tcl but there is no issue there.
It only happens on python
msg32243 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-06-07 15:31
We can't even remotely guess at the source of your exception with that info, even using our best crystal balls.

But I see that you have posted on comp.lang.python, so let's see what comes out of it there.
msg32244 - (view) Author: Alex (alexteo21) Date: 2007-06-08 10:57
Hi gbrandl,

I think I understand where the problem is.  But I am not sure if this is a bug by Python.
In the code, I am using pexpect module which spawn a child for FTP session.  After the child is closed, the file descriptor is still open (check /proc/<process>/fd)

I believe that this cause the too many file open issue.  However, when I run the same thing on Linux, the file descriptor is closed properly 

Is this the issue with the python pty module. It seems that the pty module on linux is more stable than on solaris

Very much appreciate your comments

Thanks,
Alex
msg32245 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-06-08 17:54
It's most likely a bug in your application; you should invoke .close() on the spawn object. If you do invoke .close() and the connection still stays open, it's a bug in pexpect, please report it to the authors of pexpect. Closing as invalid.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45052
2007-06-07 10:28:52alexteo21create