subprocess help

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Apr 16 08:06:16 EDT 2014


On Wed, 16 Apr 2014 12:47:03 +0200, Влатко Станковиќ wrote:

> Hello,
> I'm having some sort of 'problem' when using subprocess calls. This is
> the code snipet that i am using:
> 
> capture_server1 = '''xvfb-run --auto-servernum ... '''
> server1_download = subprocess.Popen(shlex.split(capture_server1),
>                                     stdin=subprocess.PIPE,
>                                     stdout=subprocess.PIPE,
>                                     stderr=subprocess.PIPE)
> 
> out_s1, err_s1 = server1_download.communicate()
> time.sleep(2)

What's the difference between the server1 code (shown above) and the 
server2 code (not shown, but identical as far as I can tell)?

[...]
> The problem is the following:
> - The program runs in a loop, where subprocess is called - It runs for X
> days, sometimes 3 days, sometimes 5 days - After that i get the
> following exception:
> 
> File "/usr/lib/python2.7/subprocess.py", line 1091, in pipe_cloexec r, w
> = os.pipe()
> OSError: [Errno 24] Too many open files


You have to identify what files are remaining open. What does the xvfb-
run process do? What are the rest of the arguments?

My guess is that, depending on the arguments, sometimes xvfb-run leaves 
files open even after the process terminates. You should monitor the open 
files with lsof which is available on most Linux systems. I don't know 
how to do that on other operating systems.




-- 
Steven



More information about the Python-list mailing list