Citește codul cu atenție
import asyncio
async def worker():
try:
print("start")
await asyncio.sleep(10)
print("never")
except asyncio.CancelledError:
print("cleanup")
raise
async def main():
t = asyncio.create_task(worker())
await asyncio.sleep(0)
t.cancel()
try:
await t
except asyncio.CancelledError:
print("caught")
print("after")
asyncio.run(main())
Ce va afișa programul? Scrie aici: