[tor-commits] [sbws/master] new: destination: do not attach stream to destination
juga at torproject.org
juga at torproject.org
Thu Mar 21 18:30:42 UTC 2019
commit cc314712c3ead555c6997be18e292a4fcc69888e
Author: juga0 <juga at riseup.net>
Date: Sat Mar 16 13:18:31 2019 +0000
new: destination: do not attach stream to destination
if sbws is shutting down.
---
sbws/lib/destination.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/sbws/lib/destination.py b/sbws/lib/destination.py
index d2ffa84..21a907c 100644
--- a/sbws/lib/destination.py
+++ b/sbws/lib/destination.py
@@ -14,6 +14,7 @@ from ..globals import (
NUM_DESTINATION_ATTEMPTS_STORED,
FACTOR_INCREMENT_DESTINATION_RETRY
)
+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):
More information about the tor-commits
mailing list