mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-05 21:14:13 -04:00
chore: merge in behavior logging
This commit is contained in:
commit
da551970a6
1 changed files with 23 additions and 2 deletions
|
@ -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:
|
||||||
|
@ -813,6 +815,16 @@ class Browser:
|
||||||
# {'id': 8, 'result': {'result': {'type': 'boolean', 'value': False}}}
|
# {'id': 8, 'result': {'result': {'type': 'boolean', 'value': False}}}
|
||||||
# Behavior response when finished
|
# Behavior response when finished
|
||||||
# {'id': 9, 'result': {'result': {'type': 'boolean', 'value': True}}}
|
# {'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 (
|
if (
|
||||||
msg
|
msg
|
||||||
and "result" in msg
|
and "result" in msg
|
||||||
|
@ -824,11 +836,20 @@ 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"]
|
||||||
):
|
):
|
||||||
|
|
||||||
|
# valid behavior response when finished
|
||||||
|
# {'id': 9, 'result': {'result': {'type': 'boolean', 'value': True}}}
|
||||||
|
elapsed = time.time() - start
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
"behavior decided it has finished after %.1fs",
|
"behavior decided it has finished after %.1fs and %s valid checks, "
|
||||||
time.time() - start,
|
"and %s invalid checks",
|
||||||
|
elapsed,
|
||||||
|
valid_behavior_checks,
|
||||||
|
invalid_behavior_checks,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
invalid_behavior_checks += 1
|
||||||
|
|
||||||
except BrowsingTimeout:
|
except BrowsingTimeout:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue