From 4cc63e0d4e4cf3299dcc0ea81616ba072ae5589d Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Thu, 22 Dec 2022 15:38:12 +0200 Subject: gh-100344: Add C implementation for `asyncio.current_task` (#100345) Co-authored-by: pranavtbhat --- Lib/asyncio/tasks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/asyncio/tasks.py') diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py index fa853283c0c..e78719de216 100644 --- a/Lib/asyncio/tasks.py +++ b/Lib/asyncio/tasks.py @@ -964,6 +964,7 @@ def _unregister_task(task): _all_tasks.discard(task) +_py_current_task = current_task _py_register_task = _register_task _py_unregister_task = _unregister_task _py_enter_task = _enter_task @@ -973,10 +974,12 @@ _py_leave_task = _leave_task try: from _asyncio import (_register_task, _unregister_task, _enter_task, _leave_task, - _all_tasks, _current_tasks) + _all_tasks, _current_tasks, + current_task) except ImportError: pass else: + _c_current_task = current_task _c_register_task = _register_task _c_unregister_task = _unregister_task _c_enter_task = _enter_task -- cgit v1.2.3