We are having some problems with the dreaded \"too many open files\" on our Ubuntu Linux machine rrunning a python Twisted application. In many places in our program, we are
If you're using Twisted, don't use subprocess
. If you were using spawnProcess instead, you wouldn't need to deal with annoying resource-management problems like this.
According to this source for the subprocess module (link) if you call communicate
you should not need to close the stdout
and stderr
pipes.
Otherwise I would try:
process.stdout.close()
process.stderr.close()
after you are done using the process
object.
For instance, when you call .read()
directly:
output = process.stdout.read()
process.stdout.close()
Look in the above module source for how communicate()
is defined and you'll see that it closes each pipe after it reads from it, so that is what you should also do.