check if source is connected before adding callback

This commit is contained in:
2021-06-09 16:33:51 +02:00
parent 859c970a45
commit 411a38e297

View File

@ -4,6 +4,9 @@ from ..cache import Cache
class CachedSource:
def __init__(self, size=1):
if not self.is_connected:
raise RuntimeError(f"{self.pvname} is not connected, cannot attach cache")
self.cache = cache = Cache(size=size)
self._cb = self.add_callback(cache.callback_append, with_ctrlvars=False)
@ -12,7 +15,3 @@ class CachedSource:
#TODO: check if source is connected before adding callback