In a long lived process at work, we started leaking file descriptors.

The problem were that subprocess.Popen._execute_child() method creates
two files descriptors through a call to os.pipe(), and after some work
it closes them. But an os.read() on the descriptor was interrupted
(EINTR), so an exception was raised, and the descriptors were not
closed... leakage!

This problem is easy to fix (I have a patch that fixes it, all tests
pass ok, see http://bugs.python.org/issue6274).

So, why this mail? I just think that the fix is ugly... it's not
elegant. It has the following structure:


errpipe_read, errpipe_write = os.pipe()
try:
    try:
        .....
        .....
        .....
        .....
        .....
        .....
    finally:
        os.close(errpipe_write)
    .....
    .....
    .....
finally:
    os.close(errpipe_read)


I just don't like a huge try/finally... but as FDs are just ints, do
you think is there a better way to handle it?

Thank you!!

Regards,

--
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to