diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2fb07..b5a478b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ * Restart the actor when it has been errored for 300 seconds instead of 30 * Set default DLI request timeout to 3 seconds. +### 🔧 Fixed + +* Restart the actor if it fails to set up the NPS. + ### ⚙️ Engineering * Use `uv` for package management. Updated workflows and Dockerfile. diff --git a/src/lvmnps/actor/actor.py b/src/lvmnps/actor/actor.py index 5a8a0ef..75991ee 100644 --- a/src/lvmnps/actor/actor.py +++ b/src/lvmnps/actor/actor.py @@ -8,6 +8,7 @@ from __future__ import annotations +import asyncio import pathlib from os import PathLike @@ -35,7 +36,7 @@ AnyPath = str | PathLike[str] -CHECK_INTERVAL: float = 30 +CHECK_INTERVAL: float = 5 NPSErrorCodes = create_error_codes( { @@ -110,7 +111,14 @@ def __init__( async def start(self, **kwargs): # pragma: no cover """Starts the actor.""" - await self.nps.setup() + try: + await self.nps.setup() + except Exception as err: + self.log.error(f"Failed to setup NPS: {err}") + self.log.error("Waiting 10 seconds and restarting ...") + + await asyncio.sleep(10) + await self.restart() return await super().start(**kwargs)