Skip to content

Instantly share code, notes, and snippets.

@agronholm
Created July 21, 2020 21:53
Show Gist options
  • Save agronholm/271e0c92dedac52d3784909379e8dc8a to your computer and use it in GitHub Desktop.
Save agronholm/271e0c92dedac52d3784909379e8dc8a to your computer and use it in GitHub Desktop.
Demonstration of cancellation fail
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