Skip to content

Conversation

@CtrlZvi
Copy link
Contributor

@CtrlZvi CtrlZvi commented May 16, 2018

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.

https://bugs.python.org/issue26819

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.
@1st1
Copy link
Member

1st1 commented May 17, 2018

@asvetlov Andrew, can you take a look?

@1st1
Copy link
Member

1st1 commented May 17, 2018

Looks OK to my eyes.

@CtrlZvi
Copy link
Contributor Author

CtrlZvi commented May 19, 2018

I noticed that the first run of test_asyncio on appveyor failed, but the rerun with -v succeeded. I've been unable to reproduce that failure locally, and I'm not seeing anything I missed, so I'm not sure what might be the problem. Are there any known issues with test_asyncio?

@asvetlov asvetlov merged commit 4151061 into python:master May 20, 2018
@miss-islington
Copy link
Contributor

Thanks @CtrlZvi for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

@asvetlov: Please replace # with GH- in the commit message next time. Thanks!

@asvetlov
Copy link
Contributor

thanks!

@bedevere-bot
Copy link

GH-7004 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 20, 2018
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 4151061)

Co-authored-by: CtrlZvi <[email protected]>
@miss-islington
Copy link
Contributor

Sorry, @CtrlZvi and @asvetlov, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 4151061855b571bf8a7579daa7875b8e243057b9 3.6

miss-islington added a commit that referenced this pull request May 20, 2018
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 4151061)

Co-authored-by: CtrlZvi <[email protected]>
@asvetlov
Copy link
Contributor

@CtrlZvi 3.6 branch is quite different from 3.7/master.
Could you backport the change by hands?

@CtrlZvi
Copy link
Contributor Author

CtrlZvi commented May 20, 2018

I will take a look!

CtrlZvi added a commit to CtrlZvi/cpython that referenced this pull request May 22, 2018
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 4151061)

Co-authored-by: CtrlZvi <[email protected]>
@bedevere-bot
Copy link

GH-7110 is a backport of this pull request to the 3.6 branch.

asvetlov pushed a commit that referenced this pull request May 25, 2018
)

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 4151061)

Co-authored-by: CtrlZvi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants