chore: merge in behavior logging

This commit is contained in:
Adam Miller 2025-01-16 11:19:30 -08:00
commit da551970a6

View File

@ -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:
@ -813,6 +815,16 @@ class Browser:
# {'id': 8, 'result': {'result': {'type': 'boolean', 'value': False}}}
# Behavior response when finished
# {'id': 9, 'result': {'result': {'type': 'boolean', 'value': True}}}
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
@ -824,11 +836,20 @@ class Browser:
and type(msg["result"]["result"]["value"]) == bool
and msg["result"]["result"]["value"]
):
# 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",
time.time() - start,
"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