mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-129289: fix crash when task finalizer is not called in asyncio (#129840)
This commit is contained in:
parent
7c156a63d3
commit
94cd2e0dde
3 changed files with 27 additions and 13 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue