From 664db8bd7ca3cc4c12c7198a7e47cbdac0d1e2d3 Mon Sep 17 00:00:00 2001 From: David Dotson Date: Thu, 20 Apr 2023 08:41:18 -0700 Subject: [PATCH 1/2] Add explicit deletion to contexts in ContextCache on empty Note: this may not be sufficient; will need to investigate that it actually succeeds in clearing contexts. --- openmmtools/cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openmmtools/cache.py b/openmmtools/cache.py index ae063a13..e9800c44 100644 --- a/openmmtools/cache.py +++ b/openmmtools/cache.py @@ -143,7 +143,8 @@ def time_to_live(self, new_time_to_live): def empty(self): """Purge the cache.""" - self._data = collections.OrderedDict() + for context in self._data: + del self._data[context] def __getitem__(self, key): # When we access data, push element at the From 33e48d8fef00453ff3a084661555a9584d150da4 Mon Sep 17 00:00:00 2001 From: David Dotson Date: Thu, 20 Apr 2023 11:11:21 -0700 Subject: [PATCH 2/2] Fix to avoid RuntimeError --- openmmtools/cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmmtools/cache.py b/openmmtools/cache.py index e9800c44..145072f2 100644 --- a/openmmtools/cache.py +++ b/openmmtools/cache.py @@ -143,7 +143,7 @@ def time_to_live(self, new_time_to_live): def empty(self): """Purge the cache.""" - for context in self._data: + for context in list(self._data.keys()): del self._data[context] def __getitem__(self, key):