This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients kevinwatters, mamulsow, neologix, ngrilly, pitrou
Date 2011-01-12.09:20:29
SpamBayes Score 2.5753673e-06
Marked as misclassified No
Message-id <1294824044.66.0.503798537803.issue3006@psf.upfronthosting.co.za>
In-reply-to
Content
> 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).
History
Date User Action Args
2011-01-12 09:20:44neologixsetrecipients: + neologix, pitrou, ngrilly, kevinwatters, mamulsow
2011-01-12 09:20:44neologixsetmessageid: <1294824044.66.0.503798537803.issue3006@psf.upfronthosting.co.za>
2011-01-12 09:20:29neologixlinkissue3006 messages
2011-01-12 09:20:29neologixcreate