You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The testcontainers.core.waiting_utils.wait_for_logs keeps waiting despite the container has exited. This can be confusing if there is a long wait time.
To Reproduce
fromtestcontainers.coreimportcontainer, waiting_utilsif__name__=="__main__":
waiting_utils.wait_for_logs(
container.DockerContainer("flyway/flyway").start(),
r"Successfully applied \d+ migrations to schema",
timeout=large_n, #
)
# >> Raised Exception has occurred: TimeoutError Container did not emit logs satisfying predicate in `large_n` seconds
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 )
```
Describe the bug
The
testcontainers.core.waiting_utils.wait_for_logs
keeps waiting despite the container has exited. This can be confusing if there is a long wait time.To Reproduce
Runtime environment
The text was updated successfully, but these errors were encountered: