Commit cc314712 authored by juga's avatar juga
Browse files

new: destination: do not attach stream to destination

if sbws is shutting down.
parent 1667e592
......@@ -14,6 +14,7 @@ from ..globals import (
from sbws import settings
log = logging.getLogger(__name__)
......@@ -98,6 +99,10 @@ def connect_to_destination_over_circuit(dest, circ_id, session, cont, max_dl):
should commence. False and an error string otherwise.
assert isinstance(dest, Destination)
log.debug("Connecting to destination over circuit.")
# Do not start if sbws is stopping
if settings.end_event.is_set():
return False, "Shutting down."
error_prefix = 'When sending HTTP HEAD to {}, '.format(dest.url)
with stem_utils.stream_building_lock:
listener = stem_utils.attach_stream_to_circuit_listener(cont, circ_id)
......@@ -205,12 +210,10 @@ class Destination:
# Timestamp of the last attempt.
last_time = self._attempts[-1][0]
# If the last attempt is older than _delta_seconds_retry,
if (datetime.datetime.utcnow()
# If the last attempt is older than _delta_seconds_retry, try again
return (datetime.datetime.utcnow()
- datetime.timedelta(seconds=self._delta_seconds_retry)
> last_time):
# And try again.
return True
> last_time)
return False
def is_functional(self):
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