Skip to content

Commit

Permalink
Restart the actor if it fails to set up the NPS
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Jan 11, 2025
1 parent 26d466d commit 1ddeafe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions src/lvmnps/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import asyncio
import pathlib
from os import PathLike

Expand Down Expand Up @@ -35,7 +36,7 @@
AnyPath = str | PathLike[str]


CHECK_INTERVAL: float = 30
CHECK_INTERVAL: float = 5

NPSErrorCodes = create_error_codes(
{
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 1ddeafe

Please sign in to comment.