Patchwork [1,of,4] worker: explain why pickle reading stream has to be unbuffered

login
register
mail settings
Submitter Manuel Jacob
Date May 22, 2022, 12:37 a.m.
Message ID <5dfd26ed9c4eeb51bbf9.1653179831@tmp>
Download mbox | patch
Permalink /patch/50983/
State New
Headers show

Comments

Manuel Jacob - May 22, 2022, 12:37 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1653164539 -7200
#      Sat May 21 22:22:19 2022 +0200
# Node ID 5dfd26ed9c4eeb51bbf910ca7450bdb65f06af81
# Parent  a17ffde1e71b1c9de5899ae8d5078e67c54ef1d3
# EXP-Topic worker-improvements
worker: explain why pickle reading stream has to be unbuffered
Yuya Nishihara - May 22, 2022, 3:03 a.m.
On Sun, 22 May 2022 02:37:11 +0200, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1653164539 -7200
> #      Sat May 21 22:22:19 2022 +0200
> # Node ID 5dfd26ed9c4eeb51bbf910ca7450bdb65f06af81
> # Parent  a17ffde1e71b1c9de5899ae8d5078e67c54ef1d3
> # EXP-Topic worker-improvements
> worker: explain why pickle reading stream has to be unbuffered

Queued the series, thanks. I didn't know that memoryview can be
a context manager.
Yuya Nishihara - May 22, 2022, 3:35 a.m.
On Sun, 22 May 2022 12:03:02 +0900, Yuya Nishihara wrote:
> On Sun, 22 May 2022 02:37:11 +0200, Manuel Jacob wrote:
> > # HG changeset patch
> > # User Manuel Jacob <me@manueljacob.de>
> > # Date 1653164539 -7200
> > #      Sat May 21 22:22:19 2022 +0200
> > # Node ID 5dfd26ed9c4eeb51bbf910ca7450bdb65f06af81
> > # Parent  a17ffde1e71b1c9de5899ae8d5078e67c54ef1d3
> > # EXP-Topic worker-improvements
> > worker: explain why pickle reading stream has to be unbuffered  
> 
> Queued the series,

Oops.

Alphare, can you handle this series?
I don't know how to deal with emailed patches these days.

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -265,6 +265,10 @@ 
     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():