Skip to content

mguentner/async_semaphore_race_condition_poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

python 3.9 / 3.10 asyncio race condition

the asyncio Semaphore in cpython has a race condition that can lead to infinite blocking due to a corrupted state of the Semaphore.

You can use this code to reproduce the issue along with a possible fix like this:

git checkout 52876860e43894b636b211643c232de44467dbef
# you are now using the bad implementation of 9d59381a5d
./main.py
# ^ will never finish
git checkout main
./main.py
# ^ will succeed

While this project is intended to highlight the blocking issue, python/cpython#93222 contains another, more extensive solution.

locks.py is taken and modified from here: https://github.com/python/cpython/blob/9d59381a5d20157930bae34e5f5a7bc5ef09fa89/Lib/asyncio/locks.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages