mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 16:50:02 +02:00
fix: autostart_tasks capbability in sub-classes
This commit is contained in:
parent
f7f64bbe92
commit
81f2281002
@ -7,6 +7,10 @@ from collections.abc import Callable
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import TYPE_CHECKING, Any, TypedDict
|
from typing import TYPE_CHECKING, Any, TypedDict
|
||||||
|
|
||||||
|
from pydase.data_service.abstract_data_service import AbstractDataService
|
||||||
|
from pydase.data_service.data_service_list import DataServiceList
|
||||||
|
from pydase.utils.helpers import get_class_and_instance_attributes
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .data_service import DataService
|
from .data_service import DataService
|
||||||
|
|
||||||
@ -110,6 +114,16 @@ class TaskManager:
|
|||||||
f"No start method found for service '{service_name}'"
|
f"No start method found for service '{service_name}'"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
attrs = get_class_and_instance_attributes(self.service)
|
||||||
|
|
||||||
|
for _, attr_value in attrs.items():
|
||||||
|
if isinstance(attr_value, AbstractDataService):
|
||||||
|
attr_value._task_manager.start_autostart_tasks()
|
||||||
|
elif isinstance(attr_value, DataServiceList):
|
||||||
|
for i, item in enumerate(attr_value):
|
||||||
|
if isinstance(item, AbstractDataService):
|
||||||
|
item._task_manager.start_autostart_tasks()
|
||||||
|
|
||||||
def _make_stop_task(self, name: str) -> Callable[..., Any]:
|
def _make_stop_task(self, name: str) -> Callable[..., Any]:
|
||||||
"""
|
"""
|
||||||
Factory function to create a 'stop_task' function for a running task.
|
Factory function to create a 'stop_task' function for a running task.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user