mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
bpo-26552: Fixed case where failing asyncio.ensure_future did not close the coroutine (#30288)
This commit is contained in:
parent
36f538c809
commit
24cc6411ad
3 changed files with 21 additions and 3 deletions
|
|
@ -18,7 +18,7 @@ from test import support
|
|||
from test.support.script_helper import assert_python_ok
|
||||
from test.support import os_helper
|
||||
from test.support import socket_helper
|
||||
|
||||
import warnings
|
||||
|
||||
MOCK_ANY = mock.ANY
|
||||
|
||||
|
|
@ -796,6 +796,17 @@ class BaseEventLoopTests(test_utils.TestCase):
|
|||
task._log_destroy_pending = False
|
||||
coro.close()
|
||||
|
||||
def test_create_task_error_closes_coro(self):
|
||||
async def test():
|
||||
pass
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.close()
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
with self.assertRaises(RuntimeError):
|
||||
asyncio.ensure_future(test(), loop=loop)
|
||||
self.assertEqual(len(w), 0)
|
||||
|
||||
|
||||
def test_create_named_task_with_default_factory(self):
|
||||
async def test():
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue