mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-24 11:41:09 +02:00
fix(device base): shut down task handler on destroy
This commit is contained in:
@ -164,6 +164,7 @@ class PSIDeviceBase(Device):
|
|||||||
"""Destroy the device."""
|
"""Destroy the device."""
|
||||||
self.on_destroy() # Call the on_destroy method
|
self.on_destroy() # Call the on_destroy method
|
||||||
self._stop_stoppable_status_objects()
|
self._stop_stoppable_status_objects()
|
||||||
|
self.task_handler.shutdown()
|
||||||
return super().destroy()
|
return super().destroy()
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
@ -155,7 +155,7 @@ class TaskHandler:
|
|||||||
task_status.set_finished()
|
task_status.set_finished()
|
||||||
finally:
|
finally:
|
||||||
with self._lock:
|
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:
|
def kill_task(self, task_status: TaskStatus) -> None:
|
||||||
"""Kill the thread
|
"""Kill the thread
|
||||||
@ -171,7 +171,7 @@ class TaskHandler:
|
|||||||
res = set_async_exc(ident, exc)
|
res = set_async_exc(ident, exc)
|
||||||
if res == 0:
|
if res == 0:
|
||||||
raise ValueError("Invalid thread ID")
|
raise ValueError("Invalid thread ID")
|
||||||
elif res > 1:
|
if res > 1:
|
||||||
set_async_exc(ident, None)
|
set_async_exc(ident, None)
|
||||||
logger.warning(f"Exception raise while kille Thread {ident}; return value: {res}")
|
logger.warning(f"Exception raise while kille Thread {ident}; return value: {res}")
|
||||||
except Exception as e: # pylint: disable=broad-except
|
except Exception as e: # pylint: disable=broad-except
|
||||||
|
Reference in New Issue
Block a user