# HG changeset patch # User Gregory Szorc # Date 1548539559 28800 # Node ID 44d752efdbceba88b39652c4c3b4efc98c7698eb # Parent 1bc01490178a97d4af903c87581bc270362bc079 keepalive: implement _close_conn() so closes are known Keepalives were not working on Python 3 because http.client.HTTPResponse was refactored to call _close_conn() instead of close(). Our custom close() is what returns inactive connections to the available state. We better support Python 3 by implementing a _close_conn(). Differential Revision: https://phab.mercurial-scm.org/D5720 diff -r 1bc01490178a -r 44d752efdbce mercurial/keepalive.py --- a/mercurial/keepalive.py Mon Jan 28 21:35:06 2019 -0500 +++ b/mercurial/keepalive.py Sat Jan 26 13:52:39 2019 -0800 @@ -403,6 +403,11 @@ _raw_read = httplib.HTTPResponse.read _raw_readinto = getattr(httplib.HTTPResponse, 'readinto', None) + # Python 2.7 has a single close() which closes the socket handle. + # This method was effectively renamed to _close_conn() in Python 3. But + # there is also a close(). _close_conn() is called by methods like + # read(). + def close(self): if self.fp: self.fp.close() @@ -411,6 +416,9 @@ self._handler._request_closed(self, self._host, self._connection) + def _close_conn(self): + self.close() + def close_connection(self): self._handler._remove_connection(self._host, self._connection, close=1) self.close()