changeset 39649:d6d094259d9c

keepalive: work around slight deficiency in vcr VCR's response type doesn't define the will_close attribute. Let's just have keepalive default to closing the socket if the will_close attribute is missing. Differential Revision: https://phab.mercurial-scm.org/D4599
author Augie Fackler <raf@durin42.com>
date Sat, 15 Sep 2018 00:19:09 -0400
parents e37a0fcd82c0
children d8f07b16abfc
files mercurial/keepalive.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/keepalive.py	Sat Sep 15 00:18:16 2018 -0400
+++ b/mercurial/keepalive.py	Sat Sep 15 00:19:09 2018 -0400
@@ -247,8 +247,10 @@
         except (socket.error, httplib.HTTPException) as err:
             raise urlerr.urlerror(err)
 
-        # if not a persistent connection, don't try to reuse it
-        if r.will_close:
+        # If not a persistent connection, don't try to reuse it. Look
+        # for this using getattr() since vcr doesn't define this
+        # attribute, and in that case always close the connection.
+        if getattr(r, r'will_close', True):
             self._cm.remove(h)
 
         if DEBUG: