]> granicus.if.org Git - python/commit
[3.6] bpo-26819: Prevent proactor double read on resume (GH-6921) (#7110)
authorCtrlZvi <viz+github@flippedperspective.com>
Fri, 25 May 2018 08:03:25 +0000 (01:03 -0700)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 25 May 2018 08:03:25 +0000 (11:03 +0300)
commit749afe81ec0a4b92ad6b89a67c82f2c04f79c5ac
treef354c53c7cee06ff6d08b6f6c33cad367bda3467
parent36f066a9747afdbc2e9376db90ae8d66399521ff
[3.6] bpo-26819: Prevent proactor double read on resume (GH-6921) (#7110)

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]