pass through all kwargs from BSCache to bsread.source

This commit is contained in:
2025-02-11 11:48:34 +01:00
parent 047a0c2478
commit ab2a77e4d7

View File

@ -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: