mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +02:00
adapt device connection component to use @task decorator
This commit is contained in:
parent
09fae01985
commit
be3011c565
@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
|
||||
import pydase.data_service
|
||||
import pydase.task
|
||||
|
||||
|
||||
class DeviceConnection(pydase.data_service.DataService):
|
||||
@ -52,7 +53,6 @@ class DeviceConnection(pydase.data_service.DataService):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self._connected = False
|
||||
self._autostart_tasks["_handle_connection"] = () # type: ignore
|
||||
self._reconnection_wait_time = 10.0
|
||||
|
||||
def connect(self) -> None:
|
||||
@ -70,6 +70,7 @@ class DeviceConnection(pydase.data_service.DataService):
|
||||
"""
|
||||
return self._connected
|
||||
|
||||
@pydase.task.task(autostart=True)
|
||||
async def _handle_connection(self) -> None:
|
||||
"""Automatically tries reconnecting to the device if it is not connected.
|
||||
This method leverages the `connect` method and the `connected` property to
|
||||
|
Loading…
x
Reference in New Issue
Block a user