[New-bugs-announce] [issue8293] HTTPSConnection.close() does not immediately close the connection.

David Andrzejewski report at bugs.python.org
Fri Apr 2 20:58:28 CEST 2010


New submission from David Andrzejewski <site+python.org at davidandrzejewski.com>:

Python 2.6.4, Windows XP.

If you run the following code:

import httplib

http_connection = httplib.HTTPConnection("192.168.192.196")
http_connection.request("GET", "/")
http_connection.sock.settimeout(20)
response = http_connection.getresponse()
data = response.read()
http_connection.close()


And then run a netstat -a, you'll see that the connection is no longer established (it'll have a status of TIME_WAIT or something along those lines).

However, if you run the following code:

import httplib

http_connection = httplib.HTTPSConnection("192.168.192.196")
http_connection.request("GET", "/")
http_connection.sock.settimeout(20)
response = http_connection.getresponse()
data = response.read()
http_connection.close()

And run a netstat, the connection will still be in the ESTABLISHED state.  The connection does not end for several minutes (or when you terminate the program).

I can get the connection to end when I want it by doing a del on the connection object and then manually running garbage collection - although that seems a bit wonky.

I'm not really sure what all the differences are between HTTPConnection and HTTPSConnection, but it seems like they should both behave the same way in this regard.

----------
components: Library (Lib)
messages: 102186
nosy: dandrzejewski
severity: normal
status: open
title: HTTPSConnection.close() does not immediately close the connection.
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8293>
_______________________________________


More information about the New-bugs-announce mailing list