]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Allow WatchLog.wait_for_line() to be called more than once
authorNicki Křížek <nicki@isc.org>
Mon, 23 Jun 2025 12:24:34 +0000 (14:24 +0200)
committerNicki Křížek <nicki@isc.org>
Fri, 18 Jul 2025 09:32:41 +0000 (11:32 +0200)
In some cases, it can be useful to be able to re-use the same WatchLog
to wait for another line.

bin/tests/system/isctest/log/watchlog.py

index 9bdcecd8abcbe1e04ffdd930e47f4ba59d2601e6..467a935ebce65f2fa7e301b405f95165666802e9 100644 (file)
@@ -77,7 +77,7 @@ class WatchLog(abc.ABC):
         `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_*()`
-        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:
         ...     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
 
-        >>> 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:
         ...     watcher.wait_for_line("foo")
         Traceback (most recent call last):
@@ -262,9 +249,6 @@ class WatchLog(abc.ABC):
         qux
         """
         regexes = self._prepare_patterns(patterns)
-
-        if self._wait_function_called:
-            raise WatchLogException("wait_for_*() was already called")
         self._wait_function_called = True
 
         deadline = time.monotonic() + self._timeout