From 3a868fec30fc592c6a4d60c021f44efd2e3fd253 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 7 Aug 2020 11:34:17 -0400 Subject: [PATCH] Cancel root nursery to trigger failure The real issue is if the root nursery gets cancelled prior to de-registration with the arbiter. This doesn't seem easy to reproduce by side effect of a KBI however that is how it was discovered in practise. --- tests/test_discovery.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 96a3908..d182f4c 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -237,9 +237,9 @@ def test_close_channel_explicit( use_signal, arb_addr, ): - """Verify that closing a stream explicitly **before** the containing - nursery tears down also results in subactor(s) deregistering from the - arbiter. + """Verify that closing a stream explicitly and killing the actor's + "root nursery" **before** the containing nursery tears down also + results in subactor(s) deregistering from the arbiter. """ async def streamer(agen): async for item in agen: @@ -264,7 +264,14 @@ def test_close_channel_explicit( finally: # XXX: THIS IS THE KEY THING that happens # **before** exiting the actor nursery block - # (i think?). + + # Kill the root nursery thus resulting in + # normal arbiter channel ops to fail during + # teardown. It doesn't seem like this is + # reliably triggered by an external SIGINT. + tractor.current_actor()._root_nursery.cancel_scope.cancel() + + # also kill off channels cuz why not await agen1.aclose() await agen2.aclose() finally: