title: How do I close the files from tempfile.mkstemp?
body: <p>On my machine Linux machine <code>ulimit -n</code> gives <code>1024</code>. This code:</p>
  
  <pre><code>from tempfile import mkstemp
  
  for n in xrange(1024 + 1):
      f, path = mkstemp()    
  </code></pre>
  
  <p>fails at the last line loop with:</p>
  
  <pre><code>Traceback (most recent call last):
    File "utest.py", line 4, in &lt;module&gt;
    File "/usr/lib/python2.7/tempfile.py", line 300, in mkstemp
    File "/usr/lib/python2.7/tempfile.py", line 235, in _mkstemp_inner
  OSError: [Errno 24] Too many open files: '/tmp/tmpc5W3CF'
  Error in sys.excepthook:
  Traceback (most recent call last):
    File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
  ImportError: No module named fileutils
  </code></pre>
  
  <p>It seems like I've opened to many files - but the <code>type</code> of <code>f</code> and <code>path</code> are simply <code>int</code> and <code>str</code> so I'm not sure how to close each file that I've opened. <strong>How do I close the files from tempfile.mkstemp?</strong></p>