From f64d603cff4b3f93268c0c08bbaef851e7b62902 Mon Sep 17 00:00:00 2001 From: gac-x05la Date: Fri, 21 Mar 2025 17:00:38 +0100 Subject: [PATCH] Zombie thread fix --- .../device_configs/microxas_test_bed.yaml | 38 +++++++++---------- tomcat_bec/devices/gigafrost/pcoedgecamera.py | 1 + .../devices/gigafrost/std_daq_client.py | 13 +++++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/tomcat_bec/device_configs/microxas_test_bed.yaml b/tomcat_bec/device_configs/microxas_test_bed.yaml index b884e06..1dd228d 100644 --- a/tomcat_bec/device_configs/microxas_test_bed.yaml +++ b/tomcat_bec/device_configs/microxas_test_bed.yaml @@ -119,25 +119,25 @@ femto_mean_curr: # readoutPriority: monitored # softwareTrigger: true -gfcam: - description: GigaFrost camera client - deviceClass: tomcat_bec.devices.GigaFrostCamera - deviceConfig: - prefix: 'X02DA-CAM-GF2:' - backend_url: 'http://sls-daq-001:8080' - auto_soft_enable: true - std_daq_live: 'tcp://129.129.95.111:20000' - std_daq_ws: 'ws://129.129.95.111:8080' - std_daq_rest: 'http://129.129.95.111:5000' - deviceTags: - - camera - - trigger - - gfcam - enabled: true - onFailure: buffer - readOnly: false - readoutPriority: monitored - softwareTrigger: true +# gfcam: +# description: GigaFrost camera client +# deviceClass: tomcat_bec.devices.GigaFrostCamera +# deviceConfig: +# prefix: 'X02DA-CAM-GF2:' +# backend_url: 'http://sls-daq-001:8080' +# auto_soft_enable: true +# std_daq_live: 'tcp://129.129.95.111:20000' +# std_daq_ws: 'ws://129.129.95.111:8080' +# std_daq_rest: 'http://129.129.95.111:5000' +# deviceTags: +# - camera +# - trigger +# - gfcam +# enabled: true +# onFailure: buffer +# readOnly: false +# readoutPriority: monitored +# softwareTrigger: true # gfdaq: # description: GigaFrost stdDAQ client diff --git a/tomcat_bec/devices/gigafrost/pcoedgecamera.py b/tomcat_bec/devices/gigafrost/pcoedgecamera.py index 220c9c6..1e8105d 100644 --- a/tomcat_bec/devices/gigafrost/pcoedgecamera.py +++ b/tomcat_bec/devices/gigafrost/pcoedgecamera.py @@ -200,6 +200,7 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase): self.file_savestop.set(0).wait() def destroy(self): + logger.warning("Destroy called") if self.backend is not None: self.backend.shutdown() super().destroy() diff --git a/tomcat_bec/devices/gigafrost/std_daq_client.py b/tomcat_bec/devices/gigafrost/std_daq_client.py index d72a502..fc4364c 100644 --- a/tomcat_bec/devices/gigafrost/std_daq_client.py +++ b/tomcat_bec/devices/gigafrost/std_daq_client.py @@ -54,7 +54,7 @@ class StdDaqClient: _status: StdDaqStatus = StdDaqStatus.UNDEFINED _status_timestamp: float | None = None _ws_recv_mutex = threading.Lock() - _ws_update_thread: threading.Thread | None = None + _ws_monitor_thread: threading.Thread | None = None _shutdown_event = threading.Event() _ws_idle_event = threading.Event() _daq_is_running = threading.Event() @@ -272,11 +272,16 @@ class StdDaqClient: """ Shutdown the StdDAQ client. """ - if self._ws_update_thread is not None: - self._ws_update_thread.join() + logger.warning("Shutting down sdtDAQ monitor") + self._shutdown_event.set() + if self._ws_monitor_thread is not None: + self._ws_monitor_thread.join() + logger.warning("Shutdown joined") if self._ws_client is not None: self._ws_client.close() self._ws_client = None + logger.warning("Shutdown complete") + def _wait_for_server_running(self): """ @@ -296,10 +301,12 @@ class StdDaqClient: callbacks. It also handles stdDAQ restarts and reconnection by itself. """ if self._ws_recv_mutex.locked(): + logger.warning("stdDAQ WS monitor loop already locked") return with self._ws_recv_mutex: while not self._shutdown_event.is_set(): + logger.warning("NI") self._wait_for_server_running() try: msg = self._ws_client.recv(timeout=0.1)