aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorKumar Aditya <kumaraditya@python.org>2025-02-10 17:03:59 +0530
committerGitHub <noreply@github.com>2025-02-10 17:03:59 +0530
commit94cd2e0ddeff83dee3254ca356d9e4396927d075 (patch)
tree781d5687680d1a26d8d167bcc0559b1577e0f485 /Lib/test/test_asyncio/test_tasks.py
parent7c156a63d3d5aadff0d40af73c0f622f7a0fcea5 (diff)
downloadcpython-94cd2e0ddeff83dee3254ca356d9e4396927d075.tar.gz
cpython-94cd2e0ddeff83dee3254ca356d9e4396927d075.zip
gh-129289: fix crash when task finalizer is not called in asyncio (#129840)
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 5a28d4c185b..de2e658bca6 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2296,6 +2296,22 @@ class BaseTaskTests:
self.assertEqual(self.all_tasks(loop=self.loop), set())
+ def test_task_not_crash_without_finalization(self):
+ Task = self.__class__.Task
+
+ class Subclass(Task):
+ def __del__(self):
+ pass
+
+ async def coro():
+ await asyncio.sleep(0.01)
+
+ task = Subclass(coro(), loop = self.loop)
+ task._log_destroy_pending = False
+
+ del task
+
+ support.gc_collect()
@mock.patch('asyncio.base_events.logger')
def test_tb_logger_not_called_after_cancel(self, m_log):