On my machine Linux machine ulimit -n gives 1024. This code:
ulimit -n
1024
from tempfile import mkstemp for n in xrange(1024 + 1): f, path =
Since mkstemp() returns a raw file descriptor, you can use os.close():
mkstemp()
import os from tempfile import mkstemp for n in xrange(1024 + 1): f, path = mkstemp() # Do something with 'f'... os.close(f)