Patchwork [2,of,4] worker: add docstring to _blockingreader

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

Comments

Manuel Jacob - May 22, 2022, 12:37 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1653164642 -7200
#      Sat May 21 22:24:02 2022 +0200
# Node ID ff98395f2742f27fa1e2e7ddbe31a3b810e470bc
# Parent  5dfd26ed9c4eeb51bbf910ca7450bdb65f06af81
# EXP-Topic worker-improvements
worker: add docstring to _blockingreader

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -69,6 +69,13 @@ 
 
 
 class _blockingreader:
+    """Wrap unbuffered stream such that pickle.load() works with it.
+
+    pickle.load() expects that calls to read() and readinto() read as many
+    bytes as requested. On EOF, it is fine to read fewer bytes. In this case,
+    pickle.load() raises an EOFError.
+    """
+
     def __init__(self, wrapped):
         self._wrapped = wrapped
 
@@ -79,7 +86,7 @@ 
     def readline(self):
         return self._wrapped.readline()
 
-    # issue multiple reads until size is fulfilled
+    # issue multiple reads until size is fulfilled (or EOF is encountered)
     def read(self, size=-1):
         if size < 0:
             return self._wrapped.readall()