-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
asyncio.Lock deadlock after cancellation #71772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The lock.py file prints DEADLOCK HERE I think the problem is that acquire() will block because of the cancelled future in _waiters, but release() has already ran so no one will wake it up. |
If you give the loop a chance to run (an await asyncio.sleep(0)) before doing the acquire) it does not deadlock. I don't understand enough of the asyncio internals to know if this is expected or a bug. |
Yes, await asyncio.sleep(0) does fix it, but it would be weird if I'm supposed to put those all over my code. I made a new reproducer now that uses 2 threads in case it's not allowed to take the same lock twice from the same thread. |
Does this repro with the latest Python 3.5.2? IIRC the lock code was (PS. These are tasks, not threads.) --Guido (mobile) On Aug 4, 2016 2:33 AM, "sss" <report@bugs.python.org> wrote: sss added the comment: Yes, await asyncio.sleep(0) does fix it, but it would be weird if I'm ---------- Python tracker <report@bugs.python.org> |
Yes I'm running python-3.5.2. |
Tentative fix is in python/asyncio#393 |
Thank you. This looks good to me |
OK, merged upstream. It'll eventually come down to Python 3.5.3 and 3.6. On Thu, Aug 4, 2016 at 1:28 PM, sss <report@bugs.python.org> wrote:
|
I might have found another pathological case not fixed by python/asyncio#393 Tested in 3.6.0b3 The deadlock.py file prints : DEADLOCK HERE |
Looks like create_waiter() entered the with-statement but didn't leave it |
Fix attempt : python/asyncio#467 |
Hi guys! Any update on this? There is still a problem when release() wakes up next waiter |
Also there is the same problem with asyncio.Condition wait() / notify() couple as it repeats the same Lock.acquire()/release() logic |
I'm really sorry, but I personally don't have time to look into this. If you have a fix in mind you can send a PR to GitHub mentioning bpi-27585. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: