From 2227721dac8ece70521fb7551d6001a03ed9bc14 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 2 Sep 2021 10:09:09 -0400 Subject: [PATCH] Only set event if entry still exists --- piker/_cacheables.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/piker/_cacheables.py b/piker/_cacheables.py index 87b700f5..7ffa29a0 100644 --- a/piker/_cacheables.py +++ b/piker/_cacheables.py @@ -174,8 +174,10 @@ async def maybe_open_ctx( log.warning(f'De-allocating resource for {key}') # terminate mngr nursery - _, no_more_users = cache.resources[ctx_key] - no_more_users.set() + entry = cache.resources.get(ctx_key) + if entry: + _, no_more_users = entry + no_more_users.set() @asynccontextmanager