I'm using the Jython 2.51 implementation of Python to write a script that repeatedly invokes another process via subprocess.Popen
and uses PIPE
to pipe stdout
and stderr
to the parent process and stdin
to the child process. After several hundred loop iterations, I seem to run out of file descriptors.
The Python subprocess documentation mentions very little about freeing file descriptors, other than the close_fds
option, which isn't described very clearly (Why should there be any file descriptors besides 0, 1 and 2 open in the first place?). I'm assuming that in CPython, reference counting takes care of the resource freeing issue. What's the proper way to make sure all descriptors get freed when one is done with a Popen
object in Jython?
Edit: Just in case it makes a difference, this is a multithreaded program, so there are several Popen
processes running simultaneously.