Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Descriptor leak in python 2.4 subprocess module

Thread Tools

Descriptor leak in python 2.4 subprocess module

Michel Lespinasse
Posts: n/a

I hit an issue with the following python code:

get_orient = subprocess.Popen (['jpegexiforient', '-n', pathfull],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE)
orient = get_orient.communicate ()[0]
orient = None

The intent of this was to read the exif orientation of a picture, or just
use None if jpegexiforient can not run.

The application worked fine on my devel machine but I noticed that on a
different host, it crashed due to running out of file descriptors.
After investigation I found out that the above code was responsible,
leaking two file descriptors per invocation if jpegexiforient is not
installed on the host.

I don't see any way to fix it in my code either, since get_orient is not
defined in the exception path, there is no way I can close its file
descriptors myself. I believe this is a bug in the subprocess module,
it should make sure to clean up after itself when getting out on the
exception path.

This is with python 2.4.4 on linux (debian etch distribution).

Hope this helps. I would prefer to be copied in any replies as I'm not
on the list (I will notice the replies after a while either way, but
it'll be faster if you can copy me).


Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to import subprocess into my '' file hiral Python 2 05-05-2010 12:56 PM
Leak or no leak ?? Richard Heathfield C Programming 4 07-10-2006 11:37 AM
Can subprocess point to file descriptor 5? Steve Quezadas Python 1 05-03-2006 09:10 AM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM
How to find file descriptor leak albright Java 5 12-16-2004 11:32 AM