[Request] [+ ] D12628: worker: fix `_blockingreader.read()` to really block
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Wed May 18 16:36:34 UTC 2022
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Maybe I'm missing something simple, but the help for `io.BytesIO.readinto` says:
Returns number of bytes read (0 for EOF), or None if the object
is set not to block and has no data to read.
and `io.BytesIO.read` says:
Return an empty bytes object at EOF.
That would seem to mean that if the _first_ internal `readinto()` of the
nonblocking `self._wrapped` returns `None` because no data is available, the caller
is tricked that EOF has been reached by returning an empty bytes object.
REPOSITORY
rHG Mercurial
BRANCH
stable
REVISION DETAIL
https://phab.mercurial-scm.org/D12628
AFFECTED FILES
mercurial/worker.py
CHANGE DETAILS
diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -109,8 +109,10 @@
while pos < size:
ret = self._wrapped.readinto(view[pos:])
- if not ret:
- break
+ if ret is None:
+ continue # nonblocking, and no data
+ elif ret == 0:
+ break # 0 -> EOF
pos += ret
del view
To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220518/19e236fb/attachment.html>
More information about the Mercurial-patches
mailing list