[PATCH 1 of 2 stable] worker: do not suppress EINTR

Manuel Jacob me at manueljacob.de
Wed May 25 00:30:29 UTC 2022


# HG changeset patch
# User Manuel Jacob <me at manueljacob.de>
# Date 1653433864 -7200
#      Wed May 25 01:11:04 2022 +0200
# Branch stable
# Node ID d058898bdd462b03c5bff38ad40d1f855ea51c23
# Parent  477b5145e1a02715f846ce017b460858a58e03b1
# EXP-Topic worker-pickle-load-EINTR
worker: do not suppress EINTR

Before this change, when IOError with errno EINTR was raised during
pickle.load(), the error was suppressed and loading from other file descriptors
was continued.

On Python 3, system calls failing with EINTR are retried (PEP 475). Therefore,
the removal of this code should not make any difference.

On Python 2, this is not generally the case. CPickle has no handling of EINTR.
In one place it misinterprets it as EOF. In another place, it will raise
IOError. However, this could happen in the middle of the stream. In this case,
if pickle tries to load from the stream later, it will behave wrongly (usually
it will raise an error, but loading of incorrect data or interpreter crashes
are thinkable).

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -301,10 +301,6 @@
                     selector.unregister(key.fileobj)
                     key.fileobj.close()
                     openpipes -= 1
-                except IOError as e:
-                    if e.errno == errno.EINTR:
-                        continue
-                    raise
     except:  # re-raises
         killworkers()
         cleanup()



More information about the Mercurial-devel mailing list