-
-
Save hynek/387f44672722171c901b8422320e8f9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
❯ python t.py | |
Traceback (most recent call last): | |
File "t.py", line 7, in tf | |
await asyncio.wait_for(con.wait(), 10) | |
File "/Users/hynek/.pyenv/versions/3.8.1/lib/python3.8/asyncio/tasks.py", line 476, in wait_for | |
await waiter | |
asyncio.exceptions.CancelledError | |
During handling of the above exception, another exception occurred: | |
Traceback (most recent call last): | |
File "t.py", line 23, in <module> | |
asyncio.run(f()) | |
File "/Users/hynek/.pyenv/versions/3.8.1/lib/python3.8/asyncio/runners.py", line 43, in run | |
return loop.run_until_complete(main) | |
File "/Users/hynek/.pyenv/versions/3.8.1/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete | |
return future.result() | |
File "t.py", line 19, in f | |
await t | |
File "t.py", line 7, in tf | |
await asyncio.wait_for(con.wait(), 10) | |
File "/Users/hynek/.pyenv/versions/3.8.1/lib/python3.8/asyncio/locks.py", line 103, in __aexit__ | |
self.release() | |
File "/Users/hynek/.pyenv/versions/3.8.1/lib/python3.8/asyncio/locks.py", line 229, in release | |
raise RuntimeError('Lock is not acquired.') | |
RuntimeError: Lock is not acquired. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
async def tf(con): | |
async with con: | |
await asyncio.wait_for(con.wait(), 10) | |
async def f(): | |
con = asyncio.Condition() | |
t = asyncio.create_task(tf(con)) | |
await asyncio.sleep(1) | |
t.cancel() | |
async with con: | |
con.notify_all() | |
await t | |
asyncio.run(f()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment