Created
July 21, 2020 21:53
-
-
Save agronholm/271e0c92dedac52d3784909379e8dc8a to your computer and use it in GitHub Desktop.
Demonstration of cancellation fail
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 curio | |
async def main(): | |
async def cancel(): | |
await curio.sleep(0.1) | |
await task.cancel(blocking=False) | |
event = curio.Event() | |
task = await curio.current_task() | |
for _ in range(2): | |
await curio.spawn(cancel, daemon=True) | |
print('waiting on the event') | |
try: | |
await event.wait() | |
except curio.TaskCancelled: | |
print('task cancelled') | |
curio.run(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment