Message126077
> 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). |
|
Date |
User |
Action |
Args |
2011-01-12 09:20:44 | neologix | set | recipients:
+ neologix, pitrou, ngrilly, kevinwatters, mamulsow |
2011-01-12 09:20:44 | neologix | set | messageid: <1294824044.66.0.503798537803.issue3006@psf.upfronthosting.co.za> |
2011-01-12 09:20:29 | neologix | link | issue3006 messages |
2011-01-12 09:20:29 | neologix | create | |
|