Commit c4f502c1 authored by juga  's avatar juga
Browse files

scanner, destination: Log all possible exceptions

that can happen from requests, so that they can later be stored in
a Result.
parent 8cbb7305
......@@ -84,8 +84,6 @@ def timed_recv_from_server(session, dest, byte_range):
start_time = time.time()
HTTP_GET_HEADERS['Range'] = byte_range
# TODO:
# - What other exceptions can this throw?
# - response.elapsed "measures the time taken between sending the first
# byte of the request and finishing parsing the headers.
# It is therefore unaffected by consuming the response content"
......@@ -94,10 +92,8 @@ def timed_recv_from_server(session, dest, byte_range):
try:
# headers are merged with the session ones, not overwritten.
session.get(dest.url, headers=HTTP_GET_HEADERS, verify=dest.verify)
# NewConnectionError will be raised when shutting down.
except (requests.exceptions.ConnectionError,
requests.exceptions.ReadTimeout,
requests.exceptions.NewConnectionError) as e:
# Catch any `requests` exception, so that it can stored in the Result
except requests.exceptions.RequestException as e:
log.debug(e)
return False, e
end_time = time.time()
......
......@@ -76,11 +76,8 @@ def connect_to_destination_over_circuit(dest, circ_id, session, cont, max_dl):
listener = stem_utils.attach_stream_to_circuit_listener(cont, circ_id)
stem_utils.add_event_listener(cont, listener, EventType.STREAM)
try:
# TODO:
# - What other exceptions can this throw?
head = session.head(dest.url, verify=dest.verify)
except (requests.exceptions.ConnectionError,
requests.exceptions.ReadTimeout) as e:
except requests.exceptions.RequestException as e:
dest.set_failure()
return False, 'Could not connect to {} over circ {} {}: {}'.format(
dest.url, circ_id, stem_utils.circuit_str(cont, circ_id), e)
......
Markdown is supported
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