From f0d2ad0b85f1ea9378ff1553ea12089a4c9c5fdc Mon Sep 17 00:00:00 2001 From: Alex Berndt Date: Mon, 2 Mar 2026 10:29:10 +0200 Subject: [PATCH] chore: parametrize timeout in .wait_for() call --- core/testcontainers/compose/compose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/testcontainers/compose/compose.py b/core/testcontainers/compose/compose.py index c959b134..1a5270a6 100644 --- a/core/testcontainers/compose/compose.py +++ b/core/testcontainers/compose/compose.py @@ -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 @@ -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) @@ -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: