File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -598,3 +598,26 @@ async def handle_value(
598
598
await nursery .start (handle_value , recv_chan , 0 )
599
599
await nursery .start (handle_value , recv_chan , 1 )
600
600
event .set ()
601
+
602
+
603
+ async def test_as_safe_channel_multi_cancel () -> None :
604
+ @as_safe_channel
605
+ async def agen () -> AsyncGenerator [None ]:
606
+ try :
607
+ yield
608
+ finally :
609
+ # this will give a warning of ASYNC120, although it's not technically a
610
+ # problem of swallowing existing exceptions
611
+ await trio .lowlevel .checkpoint ()
612
+
613
+ with trio .CancelScope () as cs :
614
+ with RaisesGroup (
615
+ RaisesGroup (
616
+ trio .Cancelled , trio .Cancelled , match = "^Exceptions from Trio nursery$"
617
+ ),
618
+ match = r"^Encountered exception during cleanup of generator object, as well as exception in the contextmanager body - unable to unwrap.$" ,
619
+ ):
620
+ async with agen () as recv_chan :
621
+ async for _ in recv_chan : # pragma: no branch
622
+ cs .cancel ()
623
+ await trio .lowlevel .checkpoint ()
You can’t perform that action at this time.
0 commit comments