Charles-Francois Natali <neolo...@free.fr> added the comment:

> I cannot figure out why the closesocket's graceful
shutdown is waiting for the Popen command to complete.

It doesn't. Your main process closes its socket. You could see it with a 
netstat/lsof (don't know under Windows).
The problem is that when you call subprocess.Popen(), there's a fork behind, 
and the child process receives a copy of the FD. That's why your socket is not 
deallocated until the subprocess completes (and closes the FD on exit).

> This problem does not show up with the equivalent os.popen command.

That's because os.popen() is implemented as subprocess.Popen with 
close_fds=True, so the socket is closed before execve is called. IMHO, setting 
close_fds=True by default is the Right Thing to do (and I think it's now done 
by default in py3k to avoid races between concurrent popen calls, in addition 
to setting pipe's FD as FD_CLOEXEC).

----------
nosy: +neologix

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3006>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to