0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

refactor(tests): ensure BEC dispatcher singleton object is renewed at each test

and add a check for dangling threads
This commit is contained in:
2024-01-19 16:19:42 +01:00
parent d281d6576c
commit d909673071
12 changed files with 81 additions and 51 deletions

View File

@ -3,6 +3,7 @@ import os
from qtpy import uic
from qtpy.QtWidgets import QMainWindow, QApplication
from bec_widgets.utils.bec_dispatcher import BECDispatcher
from bec_widgets.widgets import BECMonitor
# some default configs for demonstration purposes
@ -166,7 +167,7 @@ class ModularApp(QMainWindow):
super(ModularApp, self).__init__(parent)
# Client and device manager from BEC
self.client = bec_dispatcher.client if client is None else client
self.client = BECDispatcher().client if client is None else client
# Loading UI
current_path = os.path.dirname(__file__)
@ -187,10 +188,8 @@ class ModularApp(QMainWindow):
if __name__ == "__main__":
from bec_widgets.utils.bec_dispatcher import bec_dispatcher
# BECclient global variables
client = bec_dispatcher.client
client = BECDispatcher().client
client.start()
app = QApplication([])

View File

@ -10,6 +10,7 @@ from pyqtgraph import mkBrush, mkColor, mkPen
from pyqtgraph.Qt import QtCore, uic
from bec_widgets.utils import Crosshair, ctrl_c
from bec_widgets.utils.bec_dispatcher import BECDispatcher
# TODO implement:
@ -239,8 +240,6 @@ class PlotApp(QWidget):
if __name__ == "__main__":
import yaml
from bec_widgets.utils.bec_dispatcher import bec_dispatcher
with open("config_noworker.yaml", "r") as file:
config = yaml.safe_load(file)
@ -251,6 +250,7 @@ if __name__ == "__main__":
dap_worker = None if dap_worker == "None" else dap_worker
# BECclient global variables
bec_dispatcher = BECDispatcher()
client = bec_dispatcher.client
client.start()

View File

@ -23,6 +23,7 @@ from pyqtgraph.Qt import QtWidgets
from bec_lib import MessageEndpoints
from bec_widgets.utils import Crosshair, Colors
from bec_widgets.utils.bec_dispatcher import BECDispatcher
# TODO implement:
@ -92,7 +93,7 @@ class PlotApp(QWidget):
self.error_handler = ErrorHandler(parent=self)
# Client and device manager from BEC
self.client = bec_dispatcher.client if client is None else client
self.client = BECDispatcher().client if client is None else client
self.dev = self.client.device_manager.devices
# Loading UI
@ -692,8 +693,6 @@ if __name__ == "__main__":
import argparse
# from bec_widgets import ctrl_c
from bec_widgets.utils.bec_dispatcher import bec_dispatcher
parser = argparse.ArgumentParser(description="Plotting App")
parser.add_argument(
"--config",
@ -715,6 +714,7 @@ if __name__ == "__main__":
exit(1)
# BECclient global variables
bec_dispatcher = BECDispatcher()
client = bec_dispatcher.client
client.start()

View File

@ -13,9 +13,7 @@ from pyqtgraph import mkBrush, mkPen
from pyqtgraph.Qt import QtCore, QtWidgets, uic
from pyqtgraph.Qt.QtCore import pyqtSignal
from bec_widgets.utils import Crosshair, Colors
from bec_widgets.utils.bec_dispatcher import bec_dispatcher
# client = bec_dispatcher.client
from bec_widgets.utils.bec_dispatcher import BECDispatcher
class StreamPlot(QtWidgets.QWidget):
@ -32,7 +30,7 @@ class StreamPlot(QtWidgets.QWidget):
"""
# Client and device manager from BEC
self.client = bec_dispatcher.client if client is None else client
self.client = BECDispatcher().client if client is None else client
super(StreamPlot, self).__init__()
# Set style for pyqtgraph plots
@ -314,6 +312,7 @@ if __name__ == "__main__":
print(f"Plotting signals for: {', '.join(value.signals)}")
# Client from dispatcher
bec_dispatcher = BECDispatcher()
client = bec_dispatcher.client
app = QtWidgets.QApplication([])