Skip to content

Conversation

@fantix
Copy link
Contributor

@fantixfantix commented May 24, 2020

https://bugs.python.org/issue30064

This is reproducible by a cancel() followed directly by a retry:

done, pending=awaitasyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) ifdone: data=awaitdone.pop() else: pending.pop().cancel() data=awaitloop.sock_recv(sock, 1024)

This issue applies to all the loop.sock_* methods. Without this PR, users could work it around by adding a sleep(0):

done, pending=awaitasyncio.wait([loop.sock_recv(sock, 1024)], timeout=0.1) ifdone: data=awaitdone.pop() else: pending.pop().cancel() awaitasyncio.sleep(0) # <---- this ensures that the right reader is removeddata=awaitloop.sock_recv(sock, 1024)

@fantixfantix changed the title bpo-30064: Fix asyncio sock_recv* racing conditionbpo-30064: Fix asyncio loop.sock_* race condition issueMay 25, 2020
@fantixfantixforce-pushed the fix-issue-30064 branch 2 times, most recently from f65e373 to a246122CompareMay 25, 2020 20:20
@fantixfantix marked this pull request as ready for review May 25, 2020 22:40
@fantixfantix requested review from 1st1 and asvetlov as code ownersMay 25, 2020 22:40
@1st1
Copy link
Member

1st1 commented May 26, 2020

@asvetlov Please take a look if you have a few minutes.

@1st11st1 merged commit 210a137 into python:masterMay 27, 2020
@miss-islington
Copy link
Contributor

Thanks @fantix for the PR, and @1st1 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@1st1
Copy link
Member

1st1 commented May 27, 2020

Thanks, Fantix!

@bedevere-bot
Copy link

GH-20460 is a backport of this pull request to the 3.9 branch.

miss-islington added a commit that referenced this pull request May 27, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@fantix@1st1@miss-islington@bedevere-bot@the-knights-who-say-ni