On my machine Linux machine ulimit -n
gives 1024
. This code:
from tempfile import mkstemp
for n in xrange(1024 + 1):
f, path =
import tempfile
import os
for idx in xrange(1024 + 1):
outfd, outsock_path = tempfile.mkstemp()
outsock = os.fdopen(outfd,'w')
outsock.close()
Use os.close() to close the file descriptor:
import os
from tempfile import mkstemp
# Open a file
fd, path = mkstemp()
# Close opened file
os.close( fd )
Since mkstemp()
returns a raw file descriptor, you can use os.close():
import os
from tempfile import mkstemp
for n in xrange(1024 + 1):
f, path = mkstemp()
# Do something with 'f'...
os.close(f)