removes timeout_start_sec

I misinterpreted this option as the time to wait before starting the
task. This is apparently not what it stands for in systemd.service
This commit is contained in:
Mose Müller 2025-01-17 20:32:27 +01:00
parent f83bc0073b
commit b9a91e5ee2
3 changed files with 0 additions and 37 deletions

View File

@ -35,7 +35,6 @@ class PerInstanceTaskDescriptor(Generic[R]):
restart_sec: float,
start_limit_interval_sec: float | None,
start_limit_burst: int,
timeout_start_sec: float,
exit_on_failure: bool,
) -> None:
self.__func = func
@ -45,7 +44,6 @@ class PerInstanceTaskDescriptor(Generic[R]):
self.__restart_sec = restart_sec
self.__start_limit_interval_sec = start_limit_interval_sec
self.__start_limit_burst = start_limit_burst
self.__timeout_start_sec = timeout_start_sec
self.__exit_on_failure = exit_on_failure
def __set_name__(self, owner: type[DataService], name: str) -> None:
@ -86,7 +84,6 @@ class PerInstanceTaskDescriptor(Generic[R]):
restart_sec=self.__restart_sec,
start_limit_interval_sec=self.__start_limit_interval_sec,
start_limit_burst=self.__start_limit_burst,
timeout_start_sec=self.__timeout_start_sec,
exit_on_failure=self.__exit_on_failure,
),
)
@ -101,7 +98,6 @@ def task( # noqa: PLR0913
restart_sec: float = 1.0,
start_limit_interval_sec: float | None = None,
start_limit_burst: int = 3,
timeout_start_sec: float = 0.0,
exit_on_failure: bool = False,
) -> Callable[
[
@ -145,8 +141,6 @@ def task( # noqa: PLR0913
Configures unit start rate limiting. Tasks which are started more than
`start_limit_burst` times within an `start_limit_interval_sec` time span are
not permitted to start any more. Defaults to 3.
timeout_start_sec:
Configures the time to wait for start-up. Defaults to 0.0.
exit_on_failure:
If True, exit the service if the task fails and restart_on_failure is False
or burst limits are exceeded.
@ -194,7 +188,6 @@ def task( # noqa: PLR0913
restart_sec=restart_sec,
start_limit_interval_sec=start_limit_interval_sec,
start_limit_burst=start_limit_burst,
timeout_start_sec=timeout_start_sec,
exit_on_failure=exit_on_failure,
)

View File

@ -54,8 +54,6 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]):
Configures unit start rate limiting. Tasks which are started more than
`start_limit_burst` times within an `start_limit_interval_sec` time span are
not permitted to start any more. Defaults to 3.
timeout_start_sec:
Configures the time to wait for start-up. Defaults to 0.0.
exit_on_failure:
If True, exit the service if the task fails and restart_on_failure is False
or burst limits are exceeded.
@ -96,7 +94,6 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]):
restart_sec: float,
start_limit_interval_sec: float | None,
start_limit_burst: int,
timeout_start_sec: float,
exit_on_failure: bool,
) -> None:
super().__init__()
@ -105,7 +102,6 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]):
self._restart_sec = restart_sec
self._start_limit_interval_sec = start_limit_interval_sec
self._start_limit_burst = start_limit_burst
self._timeout_start_sec = timeout_start_sec
self._exit_on_failure = exit_on_failure
self._func_name = func.__name__
self._func = func
@ -171,8 +167,6 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]):
attempts = 0
start_time_of_start_limit_interval = None
await self._handle_startup_timeout()
while True:
try:
await self._func()
@ -194,11 +188,6 @@ class Task(pydase.data_service.data_service.DataService, Generic[R]):
await asyncio.sleep(self._restart_sec)
return None
async def _handle_startup_timeout(self) -> None:
"""Wait for the configured startup timeout."""
if self._timeout_start_sec:
await asyncio.sleep(self._timeout_start_sec)
def _handle_task_exception(
self,
exception: Exception,

View File

@ -383,25 +383,6 @@ async def test_non_exceeding_start_limit_interval_sec_and_burst(
assert service_instance.my_task.status == TaskStatus.RUNNING
@pytest.mark.asyncio(scope="function")
async def test_timeout_start_sec(caplog: LogCaptureFixture) -> None:
class MyService(pydase.DataService):
@task(timeout_start_sec=0.2)
async def my_task(self) -> None:
logger.info("Starting task.")
await asyncio.sleep(1)
service_instance = MyService()
state_manager = StateManager(service_instance)
DataServiceObserver(state_manager)
service_instance.my_task.start()
await asyncio.sleep(0.1)
assert "Starting task." not in caplog.text
await asyncio.sleep(0.2)
assert "Starting task." in caplog.text
@pytest.mark.asyncio(scope="function")
async def test_exit_on_failure(
monkeypatch: pytest.MonkeyPatch, caplog: LogCaptureFixture