cpython/Lib/asyncio
Guido van Rossum 602630ac18
bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270)
asyncio/taskgroups.py is an adaptation of taskgroup.py from EdgeDb, with the following key changes:

- Allow creating new tasks as long as the last task hasn't finished
- Raise [Base]ExceptionGroup (directly) rather than TaskGroupError deriving from MultiError
- Instead of monkey-patching the parent task's cancel() method,
  add a new public API to Task

The Task class has a new internal flag, `_cancel_requested`, which is set when `.cancel()` is called successfully. The `.cancelling()` method returns the value of this flag. Further `.cancel()` calls while this flag is set return False. To reset this flag, call `.uncancel()`.

Thus, a Task that catches and ignores `CancelledError` should call `.uncancel()` if it wants to be cancellable again; until it does so, it is deemed to be busy with uninterruptible cleanup.

This new Task API helps solve the problem where TaskGroup needs to distinguish between whether the parent task being cancelled "from the outside" vs. "from inside".

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-15 15:42:04 -08:00
..
__init__.py bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270) 2022-02-15 15:42:04 -08:00
__main__.py bpo-37028: asyncio REPL; activated via 'python -m asyncio'. (GH-13472) 2019-05-27 13:42:29 +02:00
base_events.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
base_futures.py bpo-42183: Fix a stack overflow error for asyncio Task or Future repr() (GH-23020) 2020-11-10 15:58:31 +02:00
base_subprocess.py bpo-32528: Make asyncio.CancelledError a BaseException. (GH-13528) 2019-05-27 14:45:12 +02:00
base_tasks.py bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270) 2022-02-15 15:42:04 -08:00
constants.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
coroutines.py bpo-43216: Remove @asyncio.coroutine (GH-26369) 2021-07-01 15:13:59 +02:00
events.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
exceptions.py bpo-42413: Replace concurrent.futures.TimeoutError and asyncio.TimeoutError with builtin TimeoutError (GH-30197) 2021-12-19 13:22:40 +02:00
format_helpers.py bpo-33672: Fix Task.__repr__ crash with Cython's bogus coroutines (GH-7161) 2018-05-28 16:27:34 -04:00
futures.py bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777) 2022-01-22 13:28:53 +02:00
locks.py bpo-45416: Fix use of asyncio.Condition() with explicit Lock objects (GH-28850) 2021-10-10 19:01:41 +03:00
log.py
mixins.py bpo-42392: Improve removal of *loop* parameter in asyncio primitives (GH-23499) 2020-11-25 06:50:44 -05:00
proactor_events.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
protocols.py bpo-46741: Update asyncio.protocols.BufferedProtocol docstring (31327) 2022-02-15 18:39:28 +02:00
queues.py bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777) 2022-01-22 13:28:53 +02:00
runners.py bpo-42392: Remove loop parameter from asyncio.tasks and asyncio.subprocess (GH-23521) 2020-11-28 10:21:17 +02:00
selector_events.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
sslproto.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
staggered.py Fix import path for asyncio.TimeoutError (#17691) 2019-12-24 12:46:42 +02:00
streams.py bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() (GH-23554) 2021-04-25 13:40:44 +03:00
subprocess.py bpo-42392: Remove loop parameter from asyncio.tasks and asyncio.subprocess (GH-23521) 2020-11-28 10:21:17 +02:00
taskgroups.py bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270) 2022-02-15 15:42:04 -08:00
tasks.py bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270) 2022-02-15 15:42:04 -08:00
threads.py Trivial typo in docstring 2021-07-31 06:36:10 +02:00
transports.py bpo-46487: Add get_write_buffer_limits to Write and _SSLProtocol transports (GH-30958) 2022-02-01 18:05:02 +02:00
trsock.py bpo-43232: Remove previously deprecated methods on TransportSocket (GH-24538) 2021-06-30 09:19:09 +03:00
unix_events.py bpo-44011: New asyncio ssl implementation (#31275) 2022-02-15 15:04:00 +02:00
windows_events.py bpo-46310: simplify for loop in asyncio/windows_events (GH-30334) 2022-01-11 12:51:34 +02:00
windows_utils.py asyncio: __del__() keep reference to warnings.warn (GH-11491) 2019-01-10 11:24:40 +01:00