From 3a9870fe4ea8d8e631567d62f823470a64387c36 Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Fri, 24 Apr 2026 11:03:19 +0100 Subject: [PATCH] fix: Clear client caches when environment is reloaded --- src/blueapi/client/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blueapi/client/client.py b/src/blueapi/client/client.py index 417d7df01..f97d3b7d5 100644 --- a/src/blueapi/client/client.py +++ b/src/blueapi/client/client.py @@ -3,6 +3,7 @@ import time from collections.abc import Iterable from concurrent.futures import Future +from contextlib import suppress from functools import cached_property from itertools import chain from pathlib import Path @@ -661,6 +662,11 @@ def reload_environment( try: status = self._rest.delete_environment() + # clear the cached plans/devices as they may have changed + with suppress(AttributeError): + del self.plans + with suppress(AttributeError): + del self.devices except Exception as e: raise BlueskyRemoteControlError( "Failed to tear down the environment"