Python 3.13 asyncio: Cancellation, Timeouts and Task Groups

Python 3.13 asyncio: Cancellation, Timeouts and Task Groups

Choose one answer. All questions are included, with explanations after checking. No time limit. Training target: 24/30. An original diagnostic test for Python developers maintaining concurrent services. Python 3.13, standard event loop and default task factory: cancellation delivery and state, cleanup, TaskGroup failures, exception groups, gather, deadline boundaries, shield, ownership and shutdown. Examples exclude simultaneous external/internal cancellation races, thread cancellation, custom task factories and later-version APIs. Each scenario is self-contained; this is not an official examination. Sources: https://docs.python.org/3.13/library/asyncio-task.html#asyncio.Task.cancel https://docs.python.org/3.13/library/asyncio-task.html#asyncio.Task.cancelling https://docs.python.org/3.13/library/asyncio-task.html#task-cancellation https://docs.python.org/3.13/library/asyncio-task.html#task-groups https://docs.python.org/3.13/library/asyncio-task.html#asyncio.Task.result https://docs.python.org/3.13/library/asyncio-task.html#asyncio.gather https://docs.python.org/3.13/library/asyncio-task.html#asyncio.timeout https://docs.python.org/3.13/library/asyncio-task.html#asyncio.timeout_at https://docs.python.org/3.13/library/asyncio-task.html#asyncio.shield https://docs.python.org/3.13/library/asyncio-task.html#asyncio.wait_for https://docs.python.org/3.13/library/asyncio-task.html#asyncio.wait https://docs.python.org/3.13/library/asyncio-task.html#asyncio.create_task https://docs.python.org/3.13/library/asyncio-task.html#asyncio.Task.uncancel
1 of 30
Python 3.13, standard asyncio event loop and default task factory. A started worker receives exactly one cancellation. It catches CancelledError and returns 9, without calling uncancel(). After await worker returns, what are worker.cancelled() and worker.cancelling()?