[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] scanner: make the time to wait for threads a variable
commit 7dce78a81d4f2a35ec465d91665796cff2e32851
Author: juga0 <juga@xxxxxxxxxx>
Date: Tue Jan 22 19:02:38 2019 +0000
scanner: make the time to wait for threads a variable
that depends on the HTTP request timeout.
---
sbws/core/scanner.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index 2dc8277..08fb35a 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -400,6 +400,9 @@ def main_loop(args, conf, controller, relay_list, circuit_builder, result_dump,
"""
pending_results = []
+ # Set the time to wait for a thread to finish as the half of an HTTP
+ # request timeout.
+ time_to_sleep = conf.getfloat('general', 'http_timeout') / 2
# Do not start a new loop if sbws is stopping.
while not settings.end_event.is_set():
log.debug("Starting a new measurement loop.")
@@ -421,14 +424,14 @@ def main_loop(args, conf, controller, relay_list, circuit_builder, result_dump,
# Instead of letting apply_async to queue the relays in order until
# a thread has finished, wait here until a thread has finished.
while len(pending_results) >= max_pending_results:
- # sleep is non-blocking sine happens in the main process
- time.sleep(5)
+ # sleep is non-blocking since happens in the main process.
+ time.sleep(time_to_sleep)
pending_results = [r for r in pending_results if not r.ready()]
while len(pending_results) > 0:
log.debug("There are %s pending measurements.",
len(pending_results))
- # sleep is non-blocking sine happens in the main process
- time.sleep(5)
+ # sleep is non-blocking since happens in the main process.
+ time.sleep(time_to_sleep)
pending_results = [r for r in pending_results if not r.ready()]
loop_tstop = time.time()
loop_tdelta = (loop_tstop - loop_tstart) / 60
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits