From 4ea5c9b5db782d931fac67b56ef223c4a9fb2cde Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 6 Dec 2021 10:52:18 -0500 Subject: [PATCH] Pop context on `.open_context()` exit --- tractor/_portal.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tractor/_portal.py b/tractor/_portal.py index 82e5a5c..bdfef3e 100644 --- a/tractor/_portal.py +++ b/tractor/_portal.py @@ -395,12 +395,14 @@ class Portal: __tracebackhide__ = True fn_mod_path, fn_name = func_deats(func) + ctx = await self.actor.start_remote_task( self.channel, fn_mod_path, fn_name, kwargs ) + assert ctx._remote_func_type == 'context' msg = await ctx._recv_chan.receive() @@ -497,6 +499,9 @@ class Portal: f'value from callee `{result}`' ) + # remove the context from runtime tracking + self.actor._contexts.pop((self.channel.uid, ctx.cid)) + @dataclass class LocalPortal: