mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-02-23 16:19:49 -05:00
feat: additional behavior checking logging to inform future logic changes
This commit is contained in:
parent
eb922f5155
commit
6ef4f0a59c
@ -788,6 +788,8 @@ class Browser:
|
||||
|
||||
check_interval = min(timeout, 7)
|
||||
start = time.time()
|
||||
valid_behavior_checks = 0
|
||||
invalid_behavior_checks = 0
|
||||
while True:
|
||||
elapsed = time.time() - start
|
||||
if elapsed > timeout:
|
||||
@ -807,6 +809,16 @@ class Browser:
|
||||
lambda: self.websock_thread.received_result(msg_id), timeout=5
|
||||
)
|
||||
msg = self.websock_thread.pop_result(msg_id)
|
||||
if (
|
||||
msg
|
||||
and "result" in msg["result"]
|
||||
and type(msg["result"]["result"]["value"]) is bool
|
||||
and not msg["result"]["result"]["value"]
|
||||
):
|
||||
# valid behavior response while still running
|
||||
# {'id': 8, 'result': {'result': {'type': 'boolean', 'value': False}}}
|
||||
valid_behavior_checks += 1
|
||||
|
||||
if (
|
||||
msg
|
||||
and "result" in msg
|
||||
@ -818,8 +830,19 @@ class Browser:
|
||||
and type(msg["result"]["result"]["value"]) == bool
|
||||
and msg["result"]["result"]["value"]
|
||||
):
|
||||
self.logger.info("behavior decided it has finished")
|
||||
# valid behavior response when finished
|
||||
# {'id': 9, 'result': {'result': {'type': 'boolean', 'value': True}}}
|
||||
elapsed = time.time() - start
|
||||
self.logger.info(
|
||||
"behavior decided it has finished after %.1fs and %s valid checks, "
|
||||
"and %s invalid checks",
|
||||
elapsed,
|
||||
valid_behavior_checks,
|
||||
invalid_behavior_checks,
|
||||
)
|
||||
return
|
||||
invalid_behavior_checks += 1
|
||||
|
||||
except BrowsingTimeout:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user