cpython/Modules/clinic
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
..
_abc.c.h bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520) 2019-01-11 18:01:42 +02:00
_asynciomodule.c.h bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270) 2022-02-15 15:42:04 -08:00
_bisectmodule.c.h Update bisect docstrings (GH-26548) 2021-06-06 11:22:48 -07:00
_bz2module.c.h bpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870) 2020-10-24 21:14:23 +03:00
_codecsmodule.c.h bpo-45467: Fix IncrementalDecoder and StreamReader in the "raw-unicode-escape" codec (GH-28944) 2021-10-14 20:04:19 +03:00
_collectionsmodule.c.h bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456) 2021-09-12 13:27:50 +03:00
_contextvarsmodule.c.h bpo-32436: Implement PEP 567 (#5027) 2018-01-22 19:11:18 -05:00
_cryptmodule.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
_curses_panel.c.h bpo-1635741 port _curses_panel to multi-phase init (PEP 489) (GH-21986) 2020-09-07 17:14:25 +02:00
_cursesmodule.c.h bpo-43084: Return bool instead of int from curses.window.enclose() (GH-24398) 2021-04-05 16:50:24 +03:00
_datetimemodule.c.h bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636) 2020-05-26 18:43:38 +03:00
_dbmmodule.c.h bpo-40563: Support pathlike objects on dbm/shelve (GH-21849) 2021-09-10 15:26:16 +03:00
_elementtree.c.h bpo-45948: Remove constructor discrepancy in C version of ElementTree.XMLParser (GH-31152) 2022-02-12 10:27:02 +02:00
_gdbmmodule.c.h bpo-40563: Support pathlike objects on dbm/shelve (GH-21849) 2021-09-10 15:26:16 +03:00
_hashopenssl.c.h bpo-43669: PEP 644: Require OpenSSL 1.1.1 or newer (GH-23014) 2021-04-17 11:36:35 +02:00
_heapqmodule.c.h Let the argument clinic do the type checking for heapq (GH-20284) 2020-05-22 07:28:57 -07:00
_localemodule.c.h bpo-42208: Add _locale._get_locale_encoding() (GH-23052) 2020-10-31 01:32:11 +01:00
_lsprof.c.h bpo-1635741: Port _lsprof extension to multi-phase init (PEP 489) (GH-22220) 2020-09-23 12:33:21 +02:00
_lzmamodule.c.h bpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870) 2020-10-24 21:14:23 +03:00
_opcode.c.h bpo-44725 : expose specialization stats in python (GH-27192) 2021-07-29 17:26:53 +01:00
_operator.c.h bpo-44558: Match countOf is/== treatment to c (GH-27007) 2021-07-07 22:28:09 +09:00
_pickle.c.h bpo-39435: Make the first argument of pickle.loads() positional-only. (GH-19846) 2020-05-02 09:38:01 +03:00
_queuemodule.c.h bpo-41710: Add private _PyDeadline_Get() function (GH-28674) 2021-10-01 13:29:25 +02:00
_randommodule.c.h bpo-41052: Fix pickling heap types implemented in C with protocols 0 and 1 (GH-22870) 2020-10-24 21:14:23 +03:00
_sre.c.h bpo-1635741: Convert _sre types to heap types and establish module state (PEP 384) (GH-23393) 2020-11-20 21:36:23 +09:00
_ssl.c.h bpo-43413: Fix handling keyword arguments in subclasses of some buitin classes (GH-26456) 2021-09-12 13:27:50 +03:00
_statisticsmodule.c.h bpo-37942: Improve argument clinic float converter (GH-15470) 2019-08-24 19:10:39 -07:00
_struct.c.h bpo-1635741: Port _struct to multiphase initialization (GH-23398) 2020-11-19 22:36:23 +09:00
_testmultiphase.c.h bpo-46613: Add PyType_GetModuleByDef to the public API (GH-31081) 2022-02-11 17:22:11 +01:00
_tkinter.c.h bpo-38371: Remove deprecated tkinter split() method (GH-28237) 2021-09-08 23:02:19 +03:00
_tracemalloc.c.h bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636) 2020-05-26 18:43:38 +03:00
_typingmodule.c.h bpo-44353: Implement typing.NewType __call__ method in C (#27262) 2021-07-22 23:06:54 +02:00
_weakref.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
_winapi.c.h bpo-44582: Accelerate mimetypes.init on Windows with a native accelerator (GH-27059) 2021-07-08 16:48:42 +01:00
arraymodule.c.h [codemod] Fix non-matching bracket pairs (GH-28473) 2021-09-22 01:09:00 +02:00
audioop.c.h bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443) 2020-05-28 10:33:45 +03:00
binascii.c.h bpo-45085: Remove the binhex module (GH-28117) 2021-09-02 12:10:08 +02:00
cmathmodule.c.h bpo-38835: Don't use PyFPE_START_PROTECT and PyFPE_END_PROTECT (GH-17231) 2019-11-20 02:51:30 +01:00
fcntlmodule.c.h bpo-41985: Add _PyLong_FileDescriptor_Converter and AC converter for "fildes". (GH-22620) 2020-10-09 23:00:45 +03:00
gcmodule.c.h bpo-37999: No longer use __int__ in implicit integer conversions. (GH-15636) 2020-05-26 18:43:38 +03:00
grpmodule.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
itertoolsmodule.c.h bpo-46728: fix docstring of combinations_with_replacement for consistency (GH-31293) 2022-02-15 09:02:21 +09:00
mathmodule.c.h bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. (GH-18604) 2020-02-23 11:21:29 +00:00
md5module.c.h bpo-1635741: Port _sha1, _sha512, _md5 to multiphase init (GH-21818) 2020-09-06 12:09:51 +02:00
overlapped.c.h bpo-20179: Convert the _overlapped module to the Argument Clinic (GH-14275) 2020-07-10 20:43:37 +03:00
posixmodule.c.h bpo-46315: Add ifdef HAVE_ feature checks for WASI compatibility (GH-30507) 2022-01-13 09:46:04 +01:00
pwdmodule.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
pyexpat.c.h bpo-1635741: Port pyexpat to multi-phase init (PEP 489) (GH-22222) 2021-01-04 15:34:26 +01:00
readline.c.h bpo-43172: readline now passes its tests when built against libedit (GH-24499) 2021-02-12 12:04:46 -08:00
resource.c.h bpo-40280: Address more test failures on Emscripten (GH-31050) 2022-02-05 20:52:01 +01:00
selectmodule.c.h bpo-41857: mention timeout argument units in select.poll() and select.depoll() doc-strings (GH-22406) 2022-01-21 01:08:44 +02:00
sha1module.c.h bpo-1635741: Port _sha1, _sha512, _md5 to multiphase init (GH-21818) 2020-09-06 12:09:51 +02:00
sha256module.c.h bpo-1635741: Convert _sha256 types to heap types (GH-22134) 2020-09-08 11:16:14 +02:00
sha512module.c.h bpo-1635741: Port _sha1, _sha512, _md5 to multiphase init (GH-21818) 2020-09-06 12:09:51 +02:00
signalmodule.c.h bpo-41498: Fix build on platforms without sigset_t (GH-29770) 2021-11-25 12:28:41 +01:00
spwdmodule.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
symtablemodule.c.h bpo-37034: Display argument name on errors with keyword arguments with Argument Clinic. (GH-13593) 2019-08-29 17:49:08 +03:00
termios.c.h bpo-41818: Add termios.tcgetwinsize(), termios.tcsetwinsize(). (GH-23686) 2021-08-26 19:56:26 -07:00
unicodedata.c.h Do not use Py_ssize_clean_t (GH-25940) 2021-05-08 10:17:37 +09:00
zlibmodule.c.h bpo-43613: Faster implementation of gzip.compress and gzip.decompress (GH-27941) 2021-09-02 17:02:59 +02:00