Skip to content

Commit 08bf23f

Browse files
committed
fix(core): Reload container in wait_for_logs before checking status
The status is cached on the Model instance. Without the reload, we always see the first value that was loaded.
1 parent deb6a6a commit 08bf23f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/testcontainers/core/waiting_utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def wait_for_logs(
106106
"""
107107
if isinstance(predicate, str):
108108
predicate = re.compile(predicate, re.MULTILINE).search
109+
wrapped = container.get_wrapped_container()
109110
start = time.time()
110111
while True:
111112
duration = time.time() - start
@@ -121,6 +122,8 @@ def wait_for_logs(
121122
return duration
122123
if duration > timeout:
123124
raise TimeoutError(f"Container did not emit logs satisfying predicate in {timeout:.3f} " "seconds")
124-
if raise_on_exit and container.get_wrapped_container().status not in _NOT_EXITED_STATUSES:
125-
raise RuntimeError("Container exited before emitting logs satisfying predicate")
125+
if raise_on_exit:
126+
wrapped.reload()
127+
if wrapped.status not in _NOT_EXITED_STATUSES:
128+
raise RuntimeError("Container exited before emitting logs satisfying predicate")
126129
time.sleep(interval)

0 commit comments

Comments
 (0)