##// END OF EJS Templates
py3: remove retry on EINTR errno...
Manuel Jacob -
r50197:ee4537e3 default
parent child Browse files
Show More
@@ -650,12 +650,7 b' class unixforkingservice:'
650 650
651 651 def _acceptnewconnection(self, sock, selector):
652 652 h = self._servicehandler
653 try:
654 653 conn, _addr = sock.accept()
655 except socket.error as inst:
656 if inst.args[0] == errno.EINTR:
657 return
658 raise
659 654
660 655 # Future improvement: On Python 3.7, maybe gc.freeze() can be used
661 656 # to prevent COW memory from being touched by GC.
@@ -688,12 +683,7 b' class unixforkingservice:'
688 683
689 684 def _handlemainipc(self, sock, selector):
690 685 """Process messages sent from a worker"""
691 try:
692 686 path = sock.recv(32768) # large enough to receive path
693 except socket.error as inst:
694 if inst.args[0] == errno.EINTR:
695 return
696 raise
697 687 self._repoloader.load(path)
698 688
699 689 def _sigchldhandler(self, signal, frame):
@@ -704,8 +694,6 b' class unixforkingservice:'
704 694 try:
705 695 pid, _status = os.waitpid(-1, options)
706 696 except OSError as inst:
707 if inst.errno == errno.EINTR:
708 continue
709 697 if inst.errno != errno.ECHILD:
710 698 raise
711 699 # no child processes at all (reaped by other waitpid()?)
@@ -716,14 +716,7 b' def poll(fds):'
716 716
717 717 In unsupported cases, it will raise a NotImplementedError"""
718 718 try:
719 while True:
720 try:
721 719 res = select.select(fds, fds, fds)
722 break
723 except select.error as inst:
724 if inst.args[0] == errno.EINTR:
725 continue
726 raise
727 720 except ValueError: # out of range file descriptor
728 721 raise NotImplementedError()
729 722 return sorted(list(set(sum(res, []))))
@@ -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 threading
11 10 import time
12 11
@@ -65,25 +64,6 b' def fmtremaining(seconds):'
65 64 return _(b"%dy%02dw") % (years, weeks)
66 65
67 66
68 # file_write() and file_flush() of Python 2 do not restart on EINTR if
69 # the file is attached to a "slow" device (e.g. a terminal) and raise
70 # IOError. We cannot know how many bytes would be written by file_write(),
71 # but a progress text is known to be short enough to be written by a
72 # single write() syscall, so we can just retry file_write() with the whole
73 # text. (issue5532)
74 #
75 # This should be a short-term workaround. We'll need to fix every occurrence
76 # of write() to a terminal or pipe.
77 def _eintrretry(func, *args):
78 while True:
79 try:
80 return func(*args)
81 except IOError as err:
82 if err.errno == errno.EINTR:
83 continue
84 raise
85
86
87 67 class progbar:
88 68 def __init__(self, ui):
89 69 self.ui = ui
@@ -207,10 +187,10 b' class progbar:'
207 187 self._flusherr()
208 188
209 189 def _flusherr(self):
210 _eintrretry(self.ui.ferr.flush)
190 self.ui.ferr.flush()
211 191
212 192 def _writeerr(self, msg):
213 _eintrretry(self.ui.ferr.write, msg)
193 self.ui.ferr.write(msg)
214 194
215 195 def width(self):
216 196 tw = self.ui.termwidth()
@@ -184,18 +184,13 b' def _posixworker(ui, func, staticargs, a'
184 184 def waitforworkers(blocking=True):
185 185 for pid in pids.copy():
186 186 p = st = 0
187 while True:
188 187 try:
189 188 p, st = os.waitpid(pid, (0 if blocking else os.WNOHANG))
190 break
191 189 except OSError as e:
192 if e.errno == errno.EINTR:
193 continue
194 elif e.errno == errno.ECHILD:
190 if e.errno == errno.ECHILD:
195 191 # child would already be reaped, but pids yet been
196 192 # updated (maybe interrupted just after waitpid)
197 193 pids.discard(pid)
198 break
199 194 else:
200 195 raise
201 196 if not p:
@@ -302,10 +297,6 b' def _posixworker(ui, func, staticargs, a'
302 297 key.fileobj.close()
303 298 # pytype: enable=attribute-error
304 299 openpipes -= 1
305 except IOError as e:
306 if e.errno == errno.EINTR:
307 continue
308 raise
309 300 except: # re-raises
310 301 killworkers()
311 302 cleanup()
General Comments 0
You need to be logged in to leave comments. Login now