Skip to content
Snippets Groups Projects
Commit d19cdfd1 authored by Krzysztof Mochocki's avatar Krzysztof Mochocki
Browse files

Add initialization timeout to settings

parent 2f1b97a7
No related branches found
No related tags found
1 merge request!73Clive integration related fixes
...@@ -107,7 +107,9 @@ class BeekeeperCommon(BeekeeperNotificationCallbacks, ABC): ...@@ -107,7 +107,9 @@ class BeekeeperCommon(BeekeeperNotificationCallbacks, ABC):
def __wait_till_ready(self) -> None: def __wait_till_ready(self) -> None:
assert self.__notification_event_handler is not None, "Notification event handler hasn't been set" assert self.__notification_event_handler is not None, "Notification event handler hasn't been set"
if not self.__notification_event_handler.http_listening_event.wait(timeout=5): if not self.__notification_event_handler.http_listening_event.wait(
timeout=self._get_settings().initialization_timeout.total_seconds()
):
raise TimeoutError("Waiting too long for beekeeper to be up and running") raise TimeoutError("Waiting too long for beekeeper to be up and running")
def _handle_error(self, error: Error) -> None: def _handle_error(self, error: Error) -> None:
......
...@@ -16,11 +16,13 @@ class Settings(HandleSettings): ...@@ -16,11 +16,13 @@ class Settings(HandleSettings):
WORKING_DIRECTORY: ClassVar[str] = "BEEKEEPY_WORKING_DIRECTORY" WORKING_DIRECTORY: ClassVar[str] = "BEEKEEPY_WORKING_DIRECTORY"
PROPAGATE_SIGINT: ClassVar[str] = "BEEKEEPY_PROPAGATE_SIGINT" PROPAGATE_SIGINT: ClassVar[str] = "BEEKEEPY_PROPAGATE_SIGINT"
CLOSE_TIMEOUT: ClassVar[str] = "BEEKEEPY_CLOSE_TIMEOUT" CLOSE_TIMEOUT: ClassVar[str] = "BEEKEEPY_CLOSE_TIMEOUT"
INITIALIZATION_TIMEOUT: ClassVar[str] = "BEEKEEPY_INITIALIZATION_TIMEOUT"
class Defaults(HandleSettings.Defaults): class Defaults(HandleSettings.Defaults):
WORKING_DIRECTORY: ClassVar[Path] = Path.cwd() WORKING_DIRECTORY: ClassVar[Path] = Path.cwd()
PROPAGATE_SIGINT: ClassVar[bool] = True PROPAGATE_SIGINT: ClassVar[bool] = True
CLOSE_TIMEOUT: ClassVar[timedelta] = timedelta(seconds=10.0) CLOSE_TIMEOUT: ClassVar[timedelta] = timedelta(seconds=10.0)
INITIALIZATION_TIMEOUT: ClassVar[timedelta] = timedelta(seconds=5.0)
working_directory: Path | None = None working_directory: Path | None = None
"""Path, where beekeeper binary will store all it's data and logs.""" """Path, where beekeeper binary will store all it's data and logs."""
...@@ -49,6 +51,11 @@ class Settings(HandleSettings): ...@@ -49,6 +51,11 @@ class Settings(HandleSettings):
) )
"""Affects time handle waits before beekeepy closes.""" """Affects time handle waits before beekeepy closes."""
initialization_timeout: timedelta = Defaults.default_factory(
EnvironNames.INITIALIZATION_TIMEOUT,
lambda x: (Settings.Defaults.INITIALIZATION_TIMEOUT if x is None else timedelta(seconds=int(x))),
)
@property @property
def ensured_working_directory(self) -> Path: def ensured_working_directory(self) -> Path:
"""This property should be used to make sure, that path to working dir is returned. """This property should be used to make sure, that path to working dir is returned.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment