mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Allow WatchLog.wait_for_line() to be called more than once
In some cases, it can be useful to be able to re-use the same WatchLog to wait for another line.
This commit is contained in:
@@ -77,7 +77,7 @@ class WatchLog(abc.ABC):
|
|||||||
`timeout` is the number of seconds (float) to wait for each wait call.
|
`timeout` is the number of seconds (float) to wait for each wait call.
|
||||||
|
|
||||||
Every instance of this class must call one of the `wait_for_*()`
|
Every instance of this class must call one of the `wait_for_*()`
|
||||||
methods exactly once or else an `Exception` is thrown.
|
methods at least once or else an `Exception` is thrown.
|
||||||
|
|
||||||
>>> with WatchLogFromStart("/dev/null") as watcher:
|
>>> with WatchLogFromStart("/dev/null") as watcher:
|
||||||
... print("Just print something without waiting for a log line")
|
... print("Just print something without waiting for a log line")
|
||||||
@@ -85,19 +85,6 @@ class WatchLog(abc.ABC):
|
|||||||
...
|
...
|
||||||
isctest.log.watchlog.WatchLogException: wait_for_*() was not called
|
isctest.log.watchlog.WatchLogException: wait_for_*() was not called
|
||||||
|
|
||||||
>>> with WatchLogFromHere("/dev/null", timeout=0.1) as watcher:
|
|
||||||
... try:
|
|
||||||
... watcher.wait_for_line("foo")
|
|
||||||
... except TimeoutError:
|
|
||||||
... pass
|
|
||||||
... try:
|
|
||||||
... watcher.wait_for_lines({"bar": 42})
|
|
||||||
... except TimeoutError:
|
|
||||||
... pass
|
|
||||||
Traceback (most recent call last):
|
|
||||||
...
|
|
||||||
isctest.log.watchlog.WatchLogException: wait_for_*() was already called
|
|
||||||
|
|
||||||
>>> with WatchLogFromHere("/dev/null", timeout=0.0) as watcher:
|
>>> with WatchLogFromHere("/dev/null", timeout=0.0) as watcher:
|
||||||
... watcher.wait_for_line("foo")
|
... watcher.wait_for_line("foo")
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
@@ -262,9 +249,6 @@ class WatchLog(abc.ABC):
|
|||||||
qux
|
qux
|
||||||
"""
|
"""
|
||||||
regexes = self._prepare_patterns(patterns)
|
regexes = self._prepare_patterns(patterns)
|
||||||
|
|
||||||
if self._wait_function_called:
|
|
||||||
raise WatchLogException("wait_for_*() was already called")
|
|
||||||
self._wait_function_called = True
|
self._wait_function_called = True
|
||||||
|
|
||||||
deadline = time.monotonic() + self._timeout
|
deadline = time.monotonic() + self._timeout
|
||||||
|
Reference in New Issue
Block a user