##// 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 import email.mime.base as emimebase
76 import email.mime.base as emimebase
77 import email.mime.multipart as emimemultipart
77 import email.mime.multipart as emimemultipart
78 import email.utils as eutil
78 import email.utils as eutil
79 import errno
80 import os
79 import os
81 import socket
80 import socket
82
81
@@ -984,9 +983,8 b' def email(ui, repo, *revs, **opts):'
984 try:
983 try:
985 generator.flatten(m, False)
984 generator.flatten(m, False)
986 ui.write(b'\n')
985 ui.write(b'\n')
987 except IOError as inst:
986 except BrokenPipeError:
988 if inst.errno != errno.EPIPE:
987 pass
989 raise
990 else:
988 else:
991 if not sendmail:
989 if not sendmail:
992 sendmail = mail.connect(ui, mbox=mbox)
990 sendmail = mail.connect(ui, mbox=mbox)
@@ -6,7 +6,6 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8
8
9 import errno
10 import gc
9 import gc
11 import os
10 import os
12 import random
11 import random
@@ -494,9 +493,8 b' def _serverequest(ui, repo, conn, create'
494 # known exceptions are caught by dispatch.
493 # known exceptions are caught by dispatch.
495 except error.Abort as inst:
494 except error.Abort as inst:
496 ui.error(_(b'abort: %s\n') % inst.message)
495 ui.error(_(b'abort: %s\n') % inst.message)
497 except IOError as inst:
496 except BrokenPipeError:
498 if inst.errno != errno.EPIPE:
497 pass
499 raise
500 except KeyboardInterrupt:
498 except KeyboardInterrupt:
501 pass
499 pass
502 finally:
500 finally:
@@ -514,9 +512,8 b' def _serverequest(ui, repo, conn, create'
514 fin.close()
512 fin.close()
515 try:
513 try:
516 fout.close() # implicit flush() may cause another EPIPE
514 fout.close() # implicit flush() may cause another EPIPE
517 except IOError as inst:
515 except BrokenPipeError:
518 if inst.errno != errno.EPIPE:
516 pass
519 raise
520
517
521
518
522 class unixservicehandler:
519 class unixservicehandler:
@@ -290,9 +290,8 b' def _rundispatch(req):'
290 # maybe pager would quit without consuming all the output, and
290 # maybe pager would quit without consuming all the output, and
291 # SIGPIPE was raised. we cannot print anything in this case.
291 # SIGPIPE was raised. we cannot print anything in this case.
292 pass
292 pass
293 except IOError as inst:
293 except BrokenPipeError:
294 if inst.errno != errno.EPIPE:
294 pass
295 raise
296 ret = -1
295 ret = -1
297 finally:
296 finally:
298 duration = util.timer() - starttime
297 duration = util.timer() - starttime
@@ -115,9 +115,8 b' class _httprequesthandler(httpservermod.'
115 def do_write(self):
115 def do_write(self):
116 try:
116 try:
117 self.do_hgweb()
117 self.do_hgweb()
118 except socket.error as inst:
118 except BrokenPipeError:
119 if inst.errno != errno.EPIPE:
119 pass
120 raise
121
120
122 def do_POST(self):
121 def do_POST(self):
123 try:
122 try:
@@ -84,7 +84,6 b' EXTRA ATTRIBUTES AND METHODS'
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
@@ -657,14 +656,14 b' def safesend(self, str):'
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
General Comments 0
You need to be logged in to leave comments. Login now