From 9cce9dfe465942c487469d36e77ac2137c90d493 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Thu, 15 Oct 2026 14:42:54 +0000 Subject: [PATCH] refactor(utils): remove unused QtRedisMessageWaiter --- bec_widgets/utils/redis_message_waiter.py | 49 ----------------------- 1 file changed, 49 deletions(-) delete mode 100644 bec_widgets/utils/redis_message_waiter.py diff --git a/bec_widgets/utils/redis_message_waiter.py b/bec_widgets/utils/redis_message_waiter.py deleted file mode 100644 index 3ca7801b..00000000 --- a/bec_widgets/utils/redis_message_waiter.py +++ /dev/null @@ -1,49 +0,0 @@ -from bec_lib.serialization import MsgpackSerialization -from bec_lib.utils import lazy_import_from -from qtpy.QtCore import QEventLoop, QSocketNotifier, QTimer - -MessageObject = lazy_import_from("bec_lib.connector", ("MessageObject",)) - - -class QtRedisMessageWaiter: - def __init__(self, redis_connector, message_to_wait): - self.ev_loop = QEventLoop() - self.response = None - self.connector = redis_connector - self.message_to_wait = message_to_wait - # Access the managed (buffered) connection directly; the connector-level - # _redis_conn accessor is deprecated in bec_lib. - self.pubsub = redis_connector._managed_connection._redis_conn.pubsub() - self.pubsub.subscribe(self.message_to_wait.endpoint) - fd = self.pubsub.connection._sock.fileno() - self.notifier = QSocketNotifier(fd, QSocketNotifier.Read) - self.notifier.activated.connect(self._pubsub_readable) - - def _msg_received(self, msg_obj): - self.response = msg_obj.value - self.ev_loop.quit() - - def wait(self, timeout=1): - timer = QTimer() - timer.singleShot(timeout * 1000, self.ev_loop.quit) - self.ev_loop.exec_() - timer.stop() - self.notifier.setEnabled(False) - self.pubsub.close() - return self.response - - def _pubsub_readable(self, fd): - while True: - msg = self.pubsub.get_message() - if msg: - if msg["type"] == "subscribe": - # get_message buffers, so we may already have the answer - # let's check... - continue - else: - break - else: - return - channel = msg["channel"].decode() - msg = MessageObject(topic=channel, value=MsgpackSerialization.loads(msg["data"])) - self.connector._execute_callback(self._msg_received, msg, {})