Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
7dce78a8
Commit
7dce78a8
authored
Jan 22, 2019
by
juga
Browse files
scanner: make the time to wait for threads a variable
that depends on the HTTP request timeout.
parent
c9ace7de
Changes
1
Hide whitespace changes
Inline
Side-by-side
sbws/core/scanner.py
View file @
7dce78a8
...
...
@@ -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 sin
c
e 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 sin
c
e 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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment