gh-129289: fix crash when task finalizer is not called in asyncio (#129840)

This commit is contained in:
Kumar Aditya 2025-02-10 17:03:59 +05:30 committed by GitHub
parent 7c156a63d3
commit 94cd2e0dde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 13 deletions

View file

@ -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):