Skip to content

Instantly share code, notes, and snippets.

@brantfaircloth
Created November 7, 2009 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brantfaircloth/228581 to your computer and use it in GitHub Desktop.
Save brantfaircloth/228581 to your computer and use it in GitHub Desktop.
'''Problems with file descriptors remaining open when making a LOT of
subprocess calls can occasionally be solved by calling os.close() on
the file descriptor (returned by os.open() or pipe).'''
stdout, self.stderr = subprocess.Popen('primer3_core %s' % self.tf[1],\
shell=True, stdout=subprocess.PIPE, stdin=None, \
stderr=subprocess.PIPE, universal_newlines=True).communicate()
# make sure that we close the stupid ass input file or we're going
# to get the damn ValueError: filedescriptor out of range in select()
# or OSError: [Errno 24] Too many open files
os.close(self.tf[0])
@rocskyfly
Copy link

you can add a new parameter "close_fds=True" in "Popen" to have a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment