feat: additional behavior checking logging to inform future logic changes

This commit is contained in:
Adam Miller 2025-01-15 16:00:23 -08:00
parent eb922f5155
commit 6ef4f0a59c

View File

@ -788,6 +788,8 @@ class Browser:
check_interval = min(timeout, 7) check_interval = min(timeout, 7)
start = time.time() start = time.time()
valid_behavior_checks = 0
invalid_behavior_checks = 0
while True: while True:
elapsed = time.time() - start elapsed = time.time() - start
if elapsed > timeout: if elapsed > timeout:
@ -807,6 +809,16 @@ class Browser:
lambda: self.websock_thread.received_result(msg_id), timeout=5 lambda: self.websock_thread.received_result(msg_id), timeout=5
) )
msg = self.websock_thread.pop_result(msg_id) 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 ( if (
msg msg
and "result" in msg and "result" in msg
@ -818,8 +830,19 @@ class Browser:
and type(msg["result"]["result"]["value"]) == bool and type(msg["result"]["result"]["value"]) == bool
and msg["result"]["result"]["value"] 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 return
invalid_behavior_checks += 1
except BrowsingTimeout: except BrowsingTimeout:
pass pass