FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(core): Make TC_POOLING_INTERVAL/sleep_time a float by samuelhwilliams · Pull Request #839 · testcontainers/testcontainers-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 2 additions & 2 deletions core/testcontainers/core/config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def read_tc_properties() -> dict[str, str]:
@dataclass
class TestcontainersConfiguration:
max_tries: int = int(environ.get("TC_MAX_TRIES", "120"))
sleep_time: int = int(environ.get("TC_POOLING_INTERVAL", "1"))
sleep_time: float = float(environ.get("TC_POOLING_INTERVAL", "1"))
ryuk_image: str = environ.get("RYUK_CONTAINER_IMAGE", "testcontainers/ryuk:0.8.1")
ryuk_privileged: bool = get_bool_env("TESTCONTAINERS_RYUK_PRIVILEGED")
ryuk_disabled: bool = get_bool_env("TESTCONTAINERS_RYUK_DISABLED")
Expand Down Expand Up @@ -130,7 +130,7 @@ def tc_properties_get_tc_host(self) -> Union[str, None]:
return self.tc_properties.get("tc.host")

@property
def timeout(self) -> int:
def timeout(self) -> float:
return self.max_tries * self.sleep_time

@property
Expand Down
6 changes: 3 additions & 3 deletions core/testcontainers/core/waiting_utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class WaitStrategy(ABC):
"""Base class for all wait strategies."""

def __init__(self) -> None:
self._startup_timeout: int = config.timeout
self._startup_timeout: float = config.timeout
self._poll_interval: float = config.sleep_time

def with_startup_timeout(self, timeout: Union[int, timedelta]) -> "WaitStrategy":
"""Set the maximum time to wait for the container to be ready."""
if isinstance(timeout, timedelta):
self._startup_timeout = int(timeout.total_seconds())
self._startup_timeout = float(int(timeout.total_seconds()))
else:
self._startup_timeout = timeout
self._startup_timeout = float(timeout)
return self

def with_poll_interval(self, interval: Union[float, timedelta]) -> "WaitStrategy":
Expand Down

Back | FazBrowse Home | New Git URL