##// END OF EJS Templates
py3: catch BrokenPipeError instead of checking errno == EPIPE
Manuel Jacob -
r50199:48f1b314 default
parent child Browse files
Show More
@@ -76,7 +76,6 b' import email.encoders as emailencoders'
76 76 import email.mime.base as emimebase
77 77 import email.mime.multipart as emimemultipart
78 78 import email.utils as eutil
79 import errno
80 79 import os
81 80 import socket
82 81
@@ -984,9 +983,8 b' def email(ui, repo, *revs, **opts):'
984 983 try:
985 984 generator.flatten(m, False)
986 985 ui.write(b'\n')
987 except IOError as inst:
988 if inst.errno != errno.EPIPE:
989 raise
986 except BrokenPipeError:
987 pass
990 988 else:
991 989 if not sendmail:
992 990 sendmail = mail.connect(ui, mbox=mbox)
@@ -6,7 +6,6 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8
9 import errno
10 9 import gc
11 10 import os
12 11 import random
@@ -494,9 +493,8 b' def _serverequest(ui, repo, conn, create'
494 493 # known exceptions are caught by dispatch.
495 494 except error.Abort as inst:
496 495 ui.error(_(b'abort: %s\n') % inst.message)
497 except IOError as inst:
498 if inst.errno != errno.EPIPE:
499 raise
496 except BrokenPipeError:
497 pass
500 498 except KeyboardInterrupt:
501 499 pass
502 500 finally:
@@ -514,9 +512,8 b' def _serverequest(ui, repo, conn, create'
514 512 fin.close()
515 513 try:
516 514 fout.close() # implicit flush() may cause another EPIPE
517 except IOError as inst:
518 if inst.errno != errno.EPIPE:
519 raise
515 except BrokenPipeError:
516 pass
520 517
521 518
522 519 class unixservicehandler:
@@ -290,9 +290,8 b' def _rundispatch(req):'
290 290 # maybe pager would quit without consuming all the output, and
291 291 # SIGPIPE was raised. we cannot print anything in this case.
292 292 pass
293 except IOError as inst:
294 if inst.errno != errno.EPIPE:
295 raise
293 except BrokenPipeError:
294 pass
296 295 ret = -1
297 296 finally:
298 297 duration = util.timer() - starttime
@@ -115,9 +115,8 b' class _httprequesthandler(httpservermod.'
115 115 def do_write(self):
116 116 try:
117 117 self.do_hgweb()
118 except socket.error as inst:
119 if inst.errno != errno.EPIPE:
120 raise
118 except BrokenPipeError:
119 pass
121 120
122 121 def do_POST(self):
123 122 try:
@@ -84,7 +84,6 b' EXTRA ATTRIBUTES AND METHODS'
84 84
85 85
86 86 import collections
87 import errno
88 87 import hashlib
89 88 import socket
90 89 import sys
@@ -657,14 +656,14 b' def safesend(self, str):'
657 656 else:
658 657 self.sock.sendall(str)
659 658 self.sentbytescount += len(str)
660 except socket.error as v:
661 reraise = True
662 if v.args[0] == errno.EPIPE: # Broken pipe
663 if self._HTTPConnection__state == httplib._CS_REQ_SENT:
664 self._broken_pipe_resp = None
665 self._broken_pipe_resp = self.getresponse()
666 reraise = False
667 self.close()
659 except BrokenPipeError:
660 if self._HTTPConnection__state == httplib._CS_REQ_SENT:
661 self._broken_pipe_resp = None
662 self._broken_pipe_resp = self.getresponse()
663 reraise = False
664 else:
665 reraise = True
666 self.close()
668 667 if reraise:
669 668 raise
670 669
General Comments 0
You need to be logged in to leave comments. Login now