Author vstinner
Recipients d_kagedal, gregory.p.smith, vstinner, yorick
Date 2008-09-22.16:34:03
SpamBayes Score 3.13222e-06
Marked as misclassified No
Message-id <1222101245.36.0.183544146865.issue3392@psf.upfronthosting.co.za>
In-reply-to
Content
I don't understand the problem. If you open a lot of files, the open() 
loop will stop an exception (IOError: too many open files), and so 
subprocess is not used.

If I open <limit>-1 files, subprocess._get_handles() will fail on 
os.pipe().

If I open <limit>-4 files, the script doesn't fail.

I'm using Linux. Here is my script:
---
# open <limit>-4 files
import subprocess
files = []
while 1:
    try:
        newfile = open("/etc/passwd")
    except IOError, err:
        print "ERR: %s" % err
        break
    files.append(newfile)

# use -3 to get an error
for file in files[-4:]:
    print "close"
    file.close()

# success
subprocess.Popen(["date"], stdout=subprocess.PIPE).communicate()
---
History
Date User Action Args
2008-09-22 16:34:05vstinnersetrecipients: + vstinner, gregory.p.smith, yorick, d_kagedal
2008-09-22 16:34:05vstinnersetmessageid: <1222101245.36.0.183544146865.issue3392@psf.upfronthosting.co.za>
2008-09-22 16:34:04vstinnerlinkissue3392 messages
2008-09-22 16:34:03vstinnercreate