Commit b85fb114 authored by juga's avatar juga
Browse files

scanner: add function to stop threads on SIGTERM

parent 66ee7406
''' 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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment