Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7718823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:15:42+00:00 2026-06-01T03:15:42+00:00

On my machine Linux machine ulimit -n gives 1024 . This code: from tempfile

  • 0

On my machine Linux machine ulimit -n gives 1024. This code:

from tempfile import mkstemp

for n in xrange(1024 + 1):
    f, path = mkstemp()    

fails at the last line loop with:

Traceback (most recent call last):
  File "utest.py", line 4, in <module>
  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

It seems like I’ve opened to many files – but the type of f and path are simply int and str so I’m not sure how to close each file that I’ve opened. How do I close the files from tempfile.mkstemp?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:15:43+00:00Added an answer on June 1, 2026 at 3:15 am
    import tempfile
    import os
    for idx in xrange(1024 + 1):
        outfd, outsock_path = tempfile.mkstemp()
        outsock = os.fdopen(outfd,'w')
        outsock.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a Python webservice on Linux machine (ubuntu): import soaplib import os from
I'm trying to move a MySQL database from a Linux machine to one running
I'm currently learning c++ on a linux machine. I've got the following code for
I have an export from a MYSQL database on a linux machine however when
My name is abbi My first perl script run on linux machine This script
On my linux machine I have a directory tree like this: rootDir |--123456789 |
I have source code checked out on my Linux machine. I connect to it
I have a problem sending email from a linux machine. The application sends several
I need to run some code on a Linux machine with Python 2.3.4 pre-installed.
can i achieve this with php (LINUX machine): i have php binary already running,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.