Skip to content

Commit 7a06617

Browse files
committed
Precompute TIMEOUT.
1 parent 5f5536a commit 7a06617

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

arangodb/testcontainers/arangodb/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ArangoDB container support.
33
"""
44
from os import environ
5-
from testcontainers.core.config import MAX_TRIES
5+
from testcontainers.core.config import TIMEOUT
66
from testcontainers.core.generic import DbContainer
77
from testcontainers.core.waiting_utils import wait_for_logs
88
import typing
@@ -81,4 +81,4 @@ def get_connection_url(self) -> str:
8181
return f"http://{self.get_container_host_ip()}:{port}"
8282

8383
def _connect(self) -> None:
84-
wait_for_logs(self, predicate="is ready for business", timeout=MAX_TRIES)
84+
wait_for_logs(self, predicate="is ready for business", timeout=TIMEOUT)

core/testcontainers/core/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
MAX_TRIES = int(environ.get("TC_MAX_TRIES", 120))
44
SLEEP_TIME = int(environ.get("TC_POOLING_INTERVAL", 1))
5+
TIMEOUT = MAX_TRIES * SLEEP_TIME

core/testcontainers/core/waiting_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def wrapper(wrapped: Callable, instance: Any, args: Iterable, kwargs: Mapping) -
6464
time.sleep(config.SLEEP_TIME)
6565
exception = e
6666
raise TimeoutError(
67-
f'Wait time ({config.MAX_TRIES * config.SLEEP_TIME}s) exceeded for {wrapped.__name__}'
68-
f'(args: {args}, kwargs {kwargs}). Exception: {exception}'
67+
f'Wait time ({config.TIMEOUT}s) exceeded for {wrapped.__name__}(args: {args}, kwargs '
68+
f'{kwargs}). Exception: {exception}'
6969
)
7070

7171
return wrapper

0 commit comments

Comments
 (0)