mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-07-24 15:25:40 -04:00
More accurate JS behavior timeout
If you use a JS behavior timeout smaller than 7 sec, the JS behavior will always need 7 sec because `sleep(7)` is hard-coded there. We make a minor addition to use `min(timeout, 7)` for sleep so it will finish faster when using a smaller JS behavior timeout.
This commit is contained in:
parent
16f886259d
commit
0b28a4a57f
1 changed files with 2 additions and 1 deletions
|
@ -617,6 +617,7 @@ class Browser:
|
||||||
method='Runtime.evaluate', suppress_logging=True,
|
method='Runtime.evaluate', suppress_logging=True,
|
||||||
params={'expression': behavior_script})
|
params={'expression': behavior_script})
|
||||||
|
|
||||||
|
check_interval = min(timeout, 7)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
while True:
|
while True:
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
|
@ -625,7 +626,7 @@ class Browser:
|
||||||
'behavior reached hard timeout after %.1fs', elapsed)
|
'behavior reached hard timeout after %.1fs', elapsed)
|
||||||
return
|
return
|
||||||
|
|
||||||
brozzler.sleep(7)
|
brozzler.sleep(check_interval)
|
||||||
|
|
||||||
self.websock_thread.expect_result(self._command_id.peek())
|
self.websock_thread.expect_result(self._command_id.peek())
|
||||||
msg_id = self.send_to_chrome(
|
msg_id = self.send_to_chrome(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue