Mercurial > hg
comparison mercurial/keepalive.py @ 49304:48f1b314056b
py3: catch BrokenPipeError instead of checking errno == EPIPE
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 16:54:58 +0200 |
parents | 642e31cb55f0 |
children | 8251f7cc787d |
comparison
equal
deleted
inserted
replaced
49303:dfdf85f37215 | 49304:48f1b314056b |
---|---|
82 | 82 |
83 # $Id: keepalive.py,v 1.14 2006/04/04 21:00:32 mstenner Exp $ | 83 # $Id: keepalive.py,v 1.14 2006/04/04 21:00:32 mstenner Exp $ |
84 | 84 |
85 | 85 |
86 import collections | 86 import collections |
87 import errno | |
88 import hashlib | 87 import hashlib |
89 import socket | 88 import socket |
90 import sys | 89 import sys |
91 import threading | 90 import threading |
92 | 91 |
655 self.sentbytescount += len(data) | 654 self.sentbytescount += len(data) |
656 data = read(blocksize) | 655 data = read(blocksize) |
657 else: | 656 else: |
658 self.sock.sendall(str) | 657 self.sock.sendall(str) |
659 self.sentbytescount += len(str) | 658 self.sentbytescount += len(str) |
660 except socket.error as v: | 659 except BrokenPipeError: |
661 reraise = True | 660 if self._HTTPConnection__state == httplib._CS_REQ_SENT: |
662 if v.args[0] == errno.EPIPE: # Broken pipe | 661 self._broken_pipe_resp = None |
663 if self._HTTPConnection__state == httplib._CS_REQ_SENT: | 662 self._broken_pipe_resp = self.getresponse() |
664 self._broken_pipe_resp = None | 663 reraise = False |
665 self._broken_pipe_resp = self.getresponse() | 664 else: |
666 reraise = False | 665 reraise = True |
667 self.close() | 666 self.close() |
668 if reraise: | 667 if reraise: |
669 raise | 668 raise |
670 | 669 |
671 | 670 |
672 def wrapgetresponse(cls): | 671 def wrapgetresponse(cls): |