From deb6a6a381b3f8c4c688a831083bed6dc6315769 Mon Sep 17 00:00:00 2001 From: David Ankin Date: Wed, 16 Oct 2024 09:04:12 -0400 Subject: [PATCH] fix: update wait_for_logs to not throw on "created" wait_for_logs has a mode for throwing on exit, it will now no longer treat "created" as an exit status --- core/testcontainers/core/waiting_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/testcontainers/core/waiting_utils.py b/core/testcontainers/core/waiting_utils.py index 2bd7806ba..de8fccfb2 100644 --- a/core/testcontainers/core/waiting_utils.py +++ b/core/testcontainers/core/waiting_utils.py @@ -77,6 +77,9 @@ def wait_for(condition: Callable[..., bool]) -> bool: return condition() +_NOT_EXITED_STATUSES = {"running", "created"} + + def wait_for_logs( container: "DockerContainer", predicate: Union[Callable, str], @@ -118,6 +121,6 @@ def wait_for_logs( return duration if duration > timeout: raise TimeoutError(f"Container did not emit logs satisfying predicate in {timeout:.3f} " "seconds") - if raise_on_exit and container.get_wrapped_container().status != "running": + if raise_on_exit and container.get_wrapped_container().status not in _NOT_EXITED_STATUSES: raise RuntimeError("Container exited before emitting logs satisfying predicate") time.sleep(interval)