]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-26819: Prevent proactor double read on resume (GH-6921)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 20 May 2018 10:57:32 +0000 (03:57 -0700)
committerGitHub <noreply@github.com>
Sun, 20 May 2018 10:57:32 +0000 (03:57 -0700)
commit28ea38b97b2bfbde9f387a8b90b02d05b93c895c
tree5a3fab0a016a43f18742c8e052e1eda7743b1bfe
parentf0af69faee902d4b80c07c100dbd528fd8df6832
bpo-26819: Prevent proactor double read on resume (GH-6921)

The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data.
(cherry picked from commit 4151061855b571bf8a7579daa7875b8e243057b9)

Co-authored-by: CtrlZvi <viz+github@flippedperspective.com>
Lib/asyncio/proactor_events.py
Lib/test/test_asyncio/test_proactor_events.py
Misc/NEWS.d/next/Library/2018-05-16-05-24-43.bpo-26819.taxbVT.rst [new file with mode: 0644]