|
15 | 15 | import re
|
16 | 16 | import time
|
17 | 17 | import traceback
|
18 |
| -from typing import Any, Callable, Iterable, Mapping, Optional, TYPE_CHECKING |
| 18 | +from typing import Any, Callable, Iterable, Mapping, Optional, TYPE_CHECKING, Union |
19 | 19 | import wrapt
|
20 | 20 |
|
21 | 21 | from . import config
|
@@ -76,27 +76,21 @@ def wait_for(condition: Callable[..., bool]) -> bool:
|
76 | 76 | return condition()
|
77 | 77 |
|
78 | 78 |
|
79 |
| -def wait_for_logs(container: "DockerContainer", predicate: Callable, |
| 79 | +def wait_for_logs(container: "DockerContainer", predicate: Union[Callable, str], |
80 | 80 | timeout: Optional[float] = None, interval: float = 1) -> float:
|
81 | 81 | """
|
82 | 82 | Wait for the container to emit logs satisfying the predicate.
|
83 | 83 |
|
84 |
| - Parameters |
85 |
| - ---------- |
86 |
| - container : DockerContainer |
87 |
| - Container whose logs to wait for. |
88 |
| - predicate : callable or str |
89 |
| - Predicate that should be satisfied by the logs. If a string, the it is used as the pattern |
90 |
| - for a multiline regular expression search. |
91 |
| - timeout : float or None |
92 |
| - Number of seconds to wait for the predicate to be satisfied. Defaults to wait indefinitely. |
93 |
| - interval : float |
94 |
| - Interval at which to poll the logs. |
95 |
| -
|
96 |
| - Returns |
97 |
| - ------- |
98 |
| - duration : float |
99 |
| - Number of seconds until the predicate was satisfied. |
| 84 | + Args: |
| 85 | + container: Container whose logs to wait for. |
| 86 | + predicate: Predicate that should be satisfied by the logs. If a string, the it is used as |
| 87 | + the pattern for a multiline regular expression search. |
| 88 | + timeout: Number of seconds to wait for the predicate to be satisfied. Defaults to wait |
| 89 | + indefinitely. |
| 90 | + interval: Interval at which to poll the logs. |
| 91 | +
|
| 92 | + Returns: |
| 93 | + duration: Number of seconds until the predicate was satisfied. |
100 | 94 | """
|
101 | 95 | if isinstance(predicate, str):
|
102 | 96 | predicate = re.compile(predicate, re.MULTILINE).search
|
|
0 commit comments