[Updated] D12628: worker: fix `_blockingreader.read()` to really block

mjacob (Manuel Jacob) phabricator at mercurial-scm.org
Fri May 20 09:49:25 UTC 2022


mjacob added a comment.


  `pickle.load()` requires that the passed file’s `read()` returns exactly as many bytes as was passed to its argument and `readinto()` fills the passed buffer completely; otherwise it raises the “pickle data was truncated” error or `EOFError` if unambiguously encountering EOF.
  
  For buffered streams this is the case if they are non-interactive and EOF is not reached (which we handle specifically) (according to https://docs.python.org/3/library/io.html#io.BufferedIOBase.read).
  
  However, we can’t use buffered streams because the selector checks whether the unbuffered stream is readable while we need to check that the stream passed to `pickle.load()` is readable (the bug resulting from this was fixed in 12491abf93bd87b057cb6826e36606afa1cee88a <https://phab.mercurial-scm.org/rHG12491abf93bd87b057cb6826e36606afa1cee88a>).
  
  `_blockingreader` wraps the unbuffered stream to meet the expectations of `pickle.load()` while not reading too much data to create the problem described in the previous paragraph.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D12628/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D12628

To: mharbison72, #hg-reviewers, mjacob
Cc: mjacob, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220520/cc859fc0/attachment-0002.html>


More information about the Mercurial-patches mailing list