changeset 49252:4d42a5fb70bf

worker: add docstring to _blockingreader
author Manuel Jacob <me@manueljacob.de>
date Sat, 21 May 2022 22:24:02 +0200
parents 5d28246b9acc
children 4c57ce494a4e
files mercurial/worker.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/worker.py	Sat May 21 22:22:19 2022 +0200
+++ b/mercurial/worker.py	Sat May 21 22:24:02 2022 +0200
@@ -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
 
@@ -94,7 +101,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()