# HG changeset patch # User Manuel Jacob # Date 2022-05-21 20:22:19 # Node ID 5d28246b9acc8fb9de7cc376b0194d2dc855433f # Parent ed9170ff791a760e7e6ec51fee4372263112e7b7 worker: explain why pickle reading stream has to be unbuffered diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -280,6 +280,10 @@ def _posixworker(ui, func, staticargs, a selector = selectors.DefaultSelector() for rfd, wfd in pipes: os.close(wfd) + # The stream has to be unbuffered. Otherwise, if all data is read from + # the raw file into the buffer, the selector thinks that the FD is not + # ready to read while pickle.load() could read from the buffer. This + # would delay the processing of readable items. selector.register(os.fdopen(rfd, 'rb', 0), selectors.EVENT_READ) def cleanup():