No, the fact that the connections are not closed is not a bug, it is necessary to reuse a connection for the next request.
The way httplib2
is written, it waits for the server to close the connection or for it to time out, it doesn't actively close them (execept on errors). If a connection has been closed, httplib2
will just try to reestablish it the next time it's used.
Closing the connection (as your patch to the source does) would make this impossible, every request would have to use it's own connection.
Destroying the httplib2.Http
object should automatically close the open connections as they are only referenced in it's connections
dictionary, so if you don't keep any references to the Http
objects you created it should work. Are you sure you don't have any references hanging around?
Alternatively you could pass a Connnection: close
header to your request:
http.request("http://example.org", headers={'Connection': 'close'})
That should cause the server to close the connection after each request. Or, you could try to manually close all connections in the object's connections
dict.