bpo-32250: Implement asyncio.current_task() and asyncio.all_tasks() by asvetlov · Pull Request #4799 · python/cpython (original) (raw)

overall LGTM.

Please apply this diff to fix tests in refleak mode:

diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 31d4ed649c..f6a1ac6f31 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -2202,6 +2202,8 @@ class BaseTaskIntrospectionTests: self.assertEqual(asyncio.all_tasks(loop), set()) self._register_task(loop, task) self.assertEqual(asyncio.all_tasks(loop), {task})

@@ -2209,6 +2211,7 @@ class BaseTaskIntrospectionTests: self.assertIsNone(asyncio.current_task(loop)) self._enter_task(loop, task) self.assertIs(asyncio.current_task(loop), task)

@@ -2218,6 +2221,7 @@ class BaseTaskIntrospectionTests: with self.assertRaises(RuntimeError): self._enter_task(loop, task2) self.assertIs(asyncio.current_task(loop), task1)

@@ -2234,6 +2238,7 @@ class BaseTaskIntrospectionTests: with self.assertRaises(RuntimeError): self._leave_task(loop, task2) self.assertIs(asyncio.current_task(loop), task1)

@@ -2246,13 +2251,13 @@ class BaseTaskIntrospectionTests: task = mock.Mock() loop = mock.Mock() self._register_task(loop, task)