diff --git a/bstrd/bscache.py b/bstrd/bscache.py index 6675b87..745361a 100644 --- a/bstrd/bscache.py +++ b/bstrd/bscache.py @@ -1,5 +1,6 @@ -from time import sleep from bsread import source, dispatcher +from bsread import BIND, CONNECT, PUSH, PULL, PUB, SUB # make these easier to access + from .bsvar import BSVar from .prodthread import ProdThread @@ -12,9 +13,10 @@ FIXED_CHANNELS = { class BSCache: - def __init__(self, timeout=1000, maxsize=100): - self.timeout = timeout - self.channels = {} + def __init__(self, maxsize=100, **kwargs): + kwargs.setdefault("receive_timeout", 1000) + self.channels = kwargs.pop("channels", {}) + self.kwargs = kwargs self.data = None self.pt = ProdThread(self.run, maxsize=maxsize) @@ -34,7 +36,7 @@ class BSCache: def run(self, running): timeout_counter = 0 configs = self.channels.values() - with source(channels=configs, receive_timeout=self.timeout) as src: + with source(channels=configs, **self.kwargs) as src: while running.is_set(): msg = src.receive() if msg is None: