Zombie thread fix

This commit is contained in:
gac-x05la
2025-03-21 17:00:38 +01:00
parent eff10e1386
commit f64d603cff
3 changed files with 30 additions and 22 deletions

View File

@@ -119,25 +119,25 @@ femto_mean_curr:
# readoutPriority: monitored # readoutPriority: monitored
# softwareTrigger: true # softwareTrigger: true
gfcam: # gfcam:
description: GigaFrost camera client # description: GigaFrost camera client
deviceClass: tomcat_bec.devices.GigaFrostCamera # deviceClass: tomcat_bec.devices.GigaFrostCamera
deviceConfig: # deviceConfig:
prefix: 'X02DA-CAM-GF2:' # prefix: 'X02DA-CAM-GF2:'
backend_url: 'http://sls-daq-001:8080' # backend_url: 'http://sls-daq-001:8080'
auto_soft_enable: true # auto_soft_enable: true
std_daq_live: 'tcp://129.129.95.111:20000' # std_daq_live: 'tcp://129.129.95.111:20000'
std_daq_ws: 'ws://129.129.95.111:8080' # std_daq_ws: 'ws://129.129.95.111:8080'
std_daq_rest: 'http://129.129.95.111:5000' # std_daq_rest: 'http://129.129.95.111:5000'
deviceTags: # deviceTags:
- camera # - camera
- trigger # - trigger
- gfcam # - gfcam
enabled: true # enabled: true
onFailure: buffer # onFailure: buffer
readOnly: false # readOnly: false
readoutPriority: monitored # readoutPriority: monitored
softwareTrigger: true # softwareTrigger: true
# gfdaq: # gfdaq:
# description: GigaFrost stdDAQ client # description: GigaFrost stdDAQ client

View File

@@ -200,6 +200,7 @@ class PcoEdge5M(PSIDeviceBase, PcoEdgeBase):
self.file_savestop.set(0).wait() self.file_savestop.set(0).wait()
def destroy(self): def destroy(self):
logger.warning("Destroy called")
if self.backend is not None: if self.backend is not None:
self.backend.shutdown() self.backend.shutdown()
super().destroy() super().destroy()

View File

@@ -54,7 +54,7 @@ class StdDaqClient:
_status: StdDaqStatus = StdDaqStatus.UNDEFINED _status: StdDaqStatus = StdDaqStatus.UNDEFINED
_status_timestamp: float | None = None _status_timestamp: float | None = None
_ws_recv_mutex = threading.Lock() _ws_recv_mutex = threading.Lock()
_ws_update_thread: threading.Thread | None = None _ws_monitor_thread: threading.Thread | None = None
_shutdown_event = threading.Event() _shutdown_event = threading.Event()
_ws_idle_event = threading.Event() _ws_idle_event = threading.Event()
_daq_is_running = threading.Event() _daq_is_running = threading.Event()
@@ -272,11 +272,16 @@ class StdDaqClient:
""" """
Shutdown the StdDAQ client. Shutdown the StdDAQ client.
""" """
if self._ws_update_thread is not None: logger.warning("Shutting down sdtDAQ monitor")
self._ws_update_thread.join() 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: if self._ws_client is not None:
self._ws_client.close() self._ws_client.close()
self._ws_client = None self._ws_client = None
logger.warning("Shutdown complete")
def _wait_for_server_running(self): def _wait_for_server_running(self):
""" """
@@ -296,10 +301,12 @@ class StdDaqClient:
callbacks. It also handles stdDAQ restarts and reconnection by itself. callbacks. It also handles stdDAQ restarts and reconnection by itself.
""" """
if self._ws_recv_mutex.locked(): if self._ws_recv_mutex.locked():
logger.warning("stdDAQ WS monitor loop already locked")
return return
with self._ws_recv_mutex: with self._ws_recv_mutex:
while not self._shutdown_event.is_set(): while not self._shutdown_event.is_set():
logger.warning("NI")
self._wait_for_server_running() self._wait_for_server_running()
try: try:
msg = self._ws_client.recv(timeout=0.1) msg = self._ws_client.recv(timeout=0.1)