Commit 925329d
authored
fix: wait_for_logs can now fail early when the container stops (#682)
Addresses my suggestion made in [issue
681](#681).
This PR adds a flag that checks is the status is not `running` and
raises a `RuntimeError` to avoid waiting for logs after the container
already has exited. The idea is to save wait time when there is a long
startup time in case the container fails early.
```python
from testcontainers.core import container, waiting_utils
if __name__ == "__main__":
waiting_utils.wait_for_logs(
container.DockerContainer("flyway/flyway").start(),
r"Successfully applied \d+ migrations to schema",
timeout=10,
raise_on_exit=True,
)
# > RuntimeError(f"Container exited before emitting logs satisfying predicate")
# ( Raised almost immediately )
```1 parent c7d9b81 commit 925329d
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
0 commit comments