[issue3006] subprocess.Popen causes socket to remain open after close

2013-05-20 Thread Charles-François Natali

Charles-François Natali added the comment:

It's fixed now that subprocess defaults to close_fds=True.

--
resolution:  - out of date
stage:  - committed/rejected
status: open - closed

___
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



[issue3006] subprocess.Popen causes socket to remain open after close

2011-06-12 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.3 -Python 2.6, Python 3.1

___
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



[issue3006] subprocess.Popen causes socket to remain open after close

2011-01-12 Thread Charles-Francois Natali

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



[issue3006] subprocess.Popen causes socket to remain open after close

2010-05-11 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 3.0

___
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



[issue3006] subprocess.Popen causes socket to remain open after close

2008-08-26 Thread Nicolas Grilly

Changes by Nicolas Grilly [EMAIL PROTECTED]:


--
nosy: +ngrilly

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3006] subprocess.Popen causes socket to remain open after close

2008-08-15 Thread Antoine Pitrou

Antoine Pitrou [EMAIL PROTECTED] added the comment:

 It's not perfect--another thread could still spawn a subprocess in
 between

Then it could be done in socketmodule.c, when still holding the GIL.
Python code can change back the socket to inheritable afterwards if it
wants to.

 We probably need some kind of API for setting socket inheritance.

Right.

--
nosy: +pitrou
priority:  - high
versions: +Python 2.6, Python 3.0 -Python 2.5

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3006] subprocess.Popen causes socket to remain open after close

2008-08-01 Thread Kevin Watters

Kevin Watters [EMAIL PROTECTED] added the comment:

I found a workaround for this issue (attached) via the kernel32.dll
function SetHandleInformation. You can patch the socket class to set all
newly created sockets as uninheritable.

It's not perfect--another thread could still spawn a subprocess in
between.  We probably need some kind of API for setting socket inheritance.

Added file: http://bugs.python.org/file11029/socketinherit.py

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3006] subprocess.Popen causes socket to remain open after close

2008-07-30 Thread Kevin Watters

Changes by Kevin Watters [EMAIL PROTECTED]:


--
nosy: +kevinwatters

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3006] subprocess.Popen causes socket to remain open after close

2008-05-29 Thread Matt Mulsow

New submission from Matt Mulsow [EMAIL PROTECTED]:

On Windows, when a suprocess.Popen command is issued while
a socket connection is being handled the socket connection
will not close until the output of the subprocess is consumed.
The connection remains open even though the request.close()
command returns successfully and the program starts listening
for the next connection.

On Windows, the request.close() call translates to the C function
closesocket. The closesocket function by default attempts to do
a graceful close in the background. By changing the linger structure,
the closesocket function can be made to do a hard close. That fixes
my problem, but then queued data may not be flushed before the
socket closes. I cannot figure out why the closesocket's graceful
shutdown is waiting for the Popen command to complete.

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

To reproduce:
run socketTest.py
use telnet to connect on port 6288
watch for connection to close or not

--
components: Library (Lib)
files: socketTest.py
messages: 67511
nosy: mamulsow
severity: normal
status: open
title: subprocess.Popen causes socket to remain open after close
type: resource usage
versions: Python 2.5
Added file: http://bugs.python.org/file10471/socketTest.py

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3006
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com