fix(device base): shut down task handler on destroy

This commit is contained in:
2025-06-16 13:40:26 +02:00
committed by Klaus Wakonig
parent cb7f7ba932
commit 3a086eee51
2 changed files with 3 additions and 2 deletions

View File

@ -164,6 +164,7 @@ class PSIDeviceBase(Device):
"""Destroy the device."""
self.on_destroy() # Call the on_destroy method
self._stop_stoppable_status_objects()
self.task_handler.shutdown()
return super().destroy()
########################################

View File

@ -155,7 +155,7 @@ class TaskHandler:
task_status.set_finished()
finally:
with self._lock:
self._tasks.pop(task_status.task_id)
self._tasks.pop(task_status.task_id, None)
def kill_task(self, task_status: TaskStatus) -> None:
"""Kill the thread
@ -171,7 +171,7 @@ class TaskHandler:
res = set_async_exc(ident, exc)
if res == 0:
raise ValueError("Invalid thread ID")
elif res > 1:
if res > 1:
set_async_exc(ident, None)
logger.warning(f"Exception raise while kille Thread {ident}; return value: {res}")
except Exception as e: # pylint: disable=broad-except