From 39b9896a62b9507901e49d76ecfa103689c5d452 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 10 Jun 2021 13:58:06 -0400 Subject: [PATCH] Only close recv chan if we get a ref --- tractor/_portal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tractor/_portal.py b/tractor/_portal.py index 0ce1a53..7f29e0e 100644 --- a/tractor/_portal.py +++ b/tractor/_portal.py @@ -359,6 +359,7 @@ class Portal: fn_mod_path, fn_name = func_deats(func) + recv_chan: trio.ReceiveMemoryChannel = None try: cid, recv_chan, functype, first_msg = await self._submit( fn_mod_path, fn_name, kwargs) @@ -390,7 +391,8 @@ class Portal: await ctx.cancel() finally: - await recv_chan.aclose() + if recv_chan is not None: + await recv_chan.aclose() @dataclass class LocalPortal: