Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
b85fb114
Commit
b85fb114
authored
6 years ago
by
juga
Browse files
Options
Downloads
Patches
Plain Diff
scanner: add function to stop threads on SIGTERM
parent
66ee7406
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sbws/core/scanner.py
+21
-0
21 additions, 0 deletions
sbws/core/scanner.py
with
21 additions
and
0 deletions
sbws/core/scanner.py
+
21
−
0
View file @
b85fb114
'''
Measure the relays.
'''
import
signal
import
sys
from
..lib.circuitbuilder
import
GapsCircuitBuilder
as
CB
from
..lib.resultdump
import
ResultDump
from
..lib.resultdump
import
ResultSuccess
,
ResultErrorCircuit
...
...
@@ -31,6 +34,24 @@ rd = None
controller
=
None
def
stop_threads
(
signal
,
frame
):
global
rd
,
pool
log
.
debug
(
'
Stopping sbws.
'
)
# Avoid new threads to start.
settings
.
set_end_event
()
# Stop Pool threads
pool
.
close
()
pool
.
join
()
# Stop ResultDump thread
rd
.
thread
.
join
()
# Stop Tor thread
controller
.
close
()
sys
.
exit
(
0
)
signal
.
signal
(
signal
.
SIGTERM
,
stop_threads
)
def
timed_recv_from_server
(
session
,
dest
,
byte_range
):
'''
Request the **byte_range** from the URL at **dest**. If successful,
return True and the time it took to download. Otherwise return False and an
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment