Issue2170

classification
Title: Sockets ends up in CLOSE_WAIT
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.5
Milestone:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: matsk, zyasoft
Priority: Keywords:

Created on 2014-06-21.09:49:41 by matsk, last changed 2014-06-23.21:16:36 by zyasoft.

Messages
msg8779 (view) Author: Mats Karlsson (matsk) Date: 2014-06-21.09:49:40
Jython leaking file descriptors. Sockets ends up in CLOSE_WAIT and then never gets garbage collected. 

To reproduce:
If you run the jython CLI in one shell and then look at the socket states in another, you can see that they ends up in CLOSE_WAIT forever.
The same problem occurs when using org.python.util.PythonInterpreter. 

 $ java -cp jython-standalone-2.5.3.jar org.python.util.jython
 >>> import urllib2
 >>> urllib2.urlopen('http://www.google.com/notfound')
 >>> urllib2.urlopen('http://www.google.com/notfound')
 >>> urllib2.urlopen('http://www.google.com/notfound')
 >>> urllib2.urlopen('http://www.google.com/notfound')
 >>> urllib2.urlopen('http://www.google.com/notfound')

To check sockets:

 $ netstat -ant|grep CLOSE
msg8781 (view) Author: Mats Karlsson (matsk) Date: 2014-06-22.03:16:24
Have the same problem with jython version 2.7b2.

 $ java -cp jython-standalone-2.7-b1.jar org.python.util.jython
 >>> import contextlib, urllib2
 >>> u = 'http://www.google.com/notfound'
 >>> with contextlib.closing(urllib2.urlopen(u)) as x:
 >>>      print x.read()
msg8806 (view) Author: Jim Baker (zyasoft) Date: 2014-06-23.18:02:09
The underlying socket implementation was "rebooted" recently in Jython 2.7. I just tried your test against trunk and didn't see CLOSE_WAIT sockets on either OS X 10.9 or Ubuntu 14.04.

Please see if this works for you in the same fashion.
msg8810 (view) Author: Mats Karlsson (matsk) Date: 2014-06-23.18:40:18
I have now tried with trunk and the problem seems to be solved. 
All good, many thanks.
You can close this bug.
msg8812 (view) Author: Jim Baker (zyasoft) Date: 2014-06-23.21:16:36
Thanks, glad we have fixed this in the reboot
History
Date User Action Args
2014-06-23 21:16:36zyasoftsetstatus: open -> closed
messages: + msg8812
2014-06-23 18:40:18matsksetmessages: + msg8810
2014-06-23 18:02:09zyasoftsetresolution: works for me
messages: + msg8806
nosy: + zyasoft
2014-06-22 03:16:25matsksetmessages: + msg8781
2014-06-21 09:49:41matskcreate