diff --git a/beekeepy/beekeepy/_handle/beekeeper.py b/beekeepy/beekeepy/_handle/beekeeper.py index 656700257d7e48ab6cd672c29c23278aaf27f798..f57b8a211db37024ba1435ccdf7631f7ef87580a 100644 --- a/beekeepy/beekeepy/_handle/beekeeper.py +++ b/beekeepy/beekeepy/_handle/beekeeper.py @@ -107,7 +107,9 @@ class BeekeeperCommon(BeekeeperNotificationCallbacks, ABC): def __wait_till_ready(self) -> None: 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") def _handle_error(self, error: Error) -> None: diff --git a/beekeepy/beekeepy/_interface/settings.py b/beekeepy/beekeepy/_interface/settings.py index a36b23314186db88188d194414ac788b1c3c13de..4f9aeee9f20f34b3ec75f3a50de13d3459fb6ca2 100644 --- a/beekeepy/beekeepy/_interface/settings.py +++ b/beekeepy/beekeepy/_interface/settings.py @@ -16,11 +16,13 @@ class Settings(HandleSettings): WORKING_DIRECTORY: ClassVar[str] = "BEEKEEPY_WORKING_DIRECTORY" PROPAGATE_SIGINT: ClassVar[str] = "BEEKEEPY_PROPAGATE_SIGINT" CLOSE_TIMEOUT: ClassVar[str] = "BEEKEEPY_CLOSE_TIMEOUT" + INITIALIZATION_TIMEOUT: ClassVar[str] = "BEEKEEPY_INITIALIZATION_TIMEOUT" class Defaults(HandleSettings.Defaults): WORKING_DIRECTORY: ClassVar[Path] = Path.cwd() PROPAGATE_SIGINT: ClassVar[bool] = True CLOSE_TIMEOUT: ClassVar[timedelta] = timedelta(seconds=10.0) + INITIALIZATION_TIMEOUT: ClassVar[timedelta] = timedelta(seconds=5.0) working_directory: Path | None = None """Path, where beekeeper binary will store all it's data and logs.""" @@ -49,6 +51,11 @@ class Settings(HandleSettings): ) """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 def ensured_working_directory(self) -> Path: """This property should be used to make sure, that path to working dir is returned.