File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import sys
55import gc
6-
76import asyncio
87import contextvars
98import contextlib
109from asyncio import taskgroups
11- import math
1210import unittest
1311import warnings
1412
@@ -1000,11 +998,13 @@ class MyKeyboardInterrupt(KeyboardInterrupt):
1000998 self .assertListEqual (gc .get_referrers (exc ), no_other_refs ())
1001999
10021000 async def test_taskgroup_stop_children (self ):
1003- async with asyncio .TaskGroup () as tg :
1004- tg .create_task (asyncio .sleep (math .inf ))
1005- tg .create_task (asyncio .sleep (math .inf ))
1006- await asyncio .sleep (0 )
1007- tg .stop ()
1001+ # (asserting that TimeoutError is not raised)
1002+ async with asyncio .timeout (1 ):
1003+ async with asyncio .TaskGroup () as tg :
1004+ tg .create_task (asyncio .sleep (10 ))
1005+ tg .create_task (asyncio .sleep (10 ))
1006+ await asyncio .sleep (0 )
1007+ tg .stop ()
10081008
10091009 async def test_taskgroup_stop_body (self ):
10101010 count = 0
@@ -1028,6 +1028,7 @@ async def test_taskgroup_stop_idempotent(self):
10281028 async def test_taskgroup_stop_after_exit (self ):
10291029 async with asyncio .TaskGroup () as tg :
10301030 await asyncio .sleep (0 )
1031+ # (asserting that exception is not raised)
10311032 tg .stop ()
10321033
10331034 async def test_taskgroup_stop_before_enter (self ):
You can’t perform that action at this time.
0 commit comments