comparison mercurial/keepalive.py @ 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 e266e75d77dc
children 1cf1680b0554
comparison
equal deleted inserted replaced
39648:e37a0fcd82c0 39649:d6d094259d9c
245 raise urlerr.urlerror( 245 raise urlerr.urlerror(
246 _('bad HTTP status line: %s') % pycompat.sysbytes(err.line)) 246 _('bad HTTP status line: %s') % pycompat.sysbytes(err.line))
247 except (socket.error, httplib.HTTPException) as err: 247 except (socket.error, httplib.HTTPException) as err:
248 raise urlerr.urlerror(err) 248 raise urlerr.urlerror(err)
249 249
250 # if not a persistent connection, don't try to reuse it 250 # If not a persistent connection, don't try to reuse it. Look
251 if r.will_close: 251 # for this using getattr() since vcr doesn't define this
252 # attribute, and in that case always close the connection.
253 if getattr(r, r'will_close', True):
252 self._cm.remove(h) 254 self._cm.remove(h)
253 255
254 if DEBUG: 256 if DEBUG:
255 DEBUG.info("STATUS: %s, %s", r.status, r.reason) 257 DEBUG.info("STATUS: %s, %s", r.status, r.reason)
256 r._handler = self 258 r._handler = self