File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -845,6 +845,28 @@ async def raise_after(t, e):
845845 pass
846846 self .assertEqual (asyncio .current_task ().cancelling (), 0 )
847847
848+ async def test_nested_groups_both_cancelled (self ):
849+ async def raise_after (t , e ):
850+ await asyncio .sleep (t )
851+ raise e ()
852+
853+ try :
854+ async with asyncio .TaskGroup () as outer_tg :
855+ try :
856+ async with asyncio .TaskGroup () as inner_tg :
857+ inner_tg .create_task (raise_after (0 , RuntimeError ))
858+ outer_tg .create_task (raise_after (0 , ValueError ))
859+ except* RuntimeError :
860+ pass
861+ else :
862+ self .fail ("RuntimeError not raised" )
863+ self .assertEqual (asyncio .current_task ().cancelling (), 1 )
864+ except* ValueError :
865+ pass
866+ else :
867+ self .fail ("ValueError not raised" )
868+ self .assertEqual (asyncio .current_task ().cancelling (), 0 )
869+
848870
849871if __name__ == "__main__" :
850872 unittest .main ()
You can’t perform that action at this time.
0 commit comments