Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/testcontainers/compose/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def get_service_host_and_port(
publisher = self.get_container(service_name).get_publisher(by_port=port).normalize()
return publisher.URL, publisher.PublishedPort

def wait_for(self, url: str) -> "DockerCompose":
def wait_for(self, url: str, timeout: int = 120) -> "DockerCompose":
"""
Waits for a response from a given URL. This is typically used to block until a service in
the environment has started and is responding. Note that it does not assert any sort of
Expand All @@ -545,6 +545,7 @@ def wait_for(self, url: str) -> "DockerCompose":

Args:
url: URL from one of the services in the environment to use to wait on.
timeout: Timeout in seconds to wait for the the services. Defaults to 120 seconds.

Example:
# Simple URL wait (legacy style)
Expand All @@ -565,7 +566,6 @@ def wait_for(self, url: str) -> "DockerCompose":
# For simple URL waiting when we have multiple containers,
# we'll do a direct HTTP check instead of using the container-based strategy
start_time = time.time()
timeout = 120 # Default timeout

while True:
if time.time() - start_time > timeout:
Expand Down