Mercurial > public > mercurial-scm > hg-stable
diff mercurial/progress.py @ 49310:ee4537e365c8
py3: remove retry on EINTR errno
Since the implementation of PEP 475 (Python 3.5), Python retries system calls
failing with EINTR. Therefore we don?t need the logic that retries it in Python
code.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Tue, 31 May 2022 04:11:34 +0200 |
parents | 642e31cb55f0 |
children | f4733654f144 |
line wrap: on
line diff
--- a/mercurial/progress.py Tue May 31 03:39:42 2022 +0200 +++ b/mercurial/progress.py Tue May 31 04:11:34 2022 +0200 @@ -6,7 +6,6 @@ # GNU General Public License version 2 or any later version. -import errno import threading import time @@ -65,25 +64,6 @@ return _(b"%dy%02dw") % (years, weeks) -# file_write() and file_flush() of Python 2 do not restart on EINTR if -# the file is attached to a "slow" device (e.g. a terminal) and raise -# IOError. We cannot know how many bytes would be written by file_write(), -# but a progress text is known to be short enough to be written by a -# single write() syscall, so we can just retry file_write() with the whole -# text. (issue5532) -# -# This should be a short-term workaround. We'll need to fix every occurrence -# of write() to a terminal or pipe. -def _eintrretry(func, *args): - while True: - try: - return func(*args) - except IOError as err: - if err.errno == errno.EINTR: - continue - raise - - class progbar: def __init__(self, ui): self.ui = ui @@ -207,10 +187,10 @@ self._flusherr() def _flusherr(self): - _eintrretry(self.ui.ferr.flush) + self.ui.ferr.flush() def _writeerr(self, msg): - _eintrretry(self.ui.ferr.write, msg) + self.ui.ferr.write(msg) def width(self): tw = self.ui.termwidth()