Skip to content

Commit

Permalink
Fix for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Aug 5, 2021
1 parent 75455da commit 31d7027
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions slack_sdk/http_retry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RateLimitErrorRetryHandler, # noqa
) # noqa
from .interval_calculator import RetryIntervalCalculator # noqa
from .builtin_interval_calculators import (
from .builtin_interval_calculators import ( # noqa
FixedValueRetryIntervalCalculator, # noqa
BackoffRetryIntervalCalculator, # noqa
) # noqa
Expand All @@ -16,11 +16,11 @@
connect_error_retry_handler = ConnectionErrorRetryHandler() # noqa
rate_limit_error_retry_handler = RateLimitErrorRetryHandler() # noqa

default_retry_handlers = [
connect_error_retry_handler,
default_retry_handlers = [ # noqa
connect_error_retry_handler, # noqa
] # noqa

all_builtin_retry_handlers = [
connect_error_retry_handler,
rate_limit_error_retry_handler,
all_builtin_retry_handlers = [ # noqa
connect_error_retry_handler, # noqa
rate_limit_error_retry_handler, # noqa
] # noqa
2 changes: 1 addition & 1 deletion slack_sdk/http_retry/builtin_interval_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ def __init__(self, backoff_factor: float = 0.5, jitter: Optional[Jitter] = None)

def calculate_sleep_duration(self, current_attempt: int) -> float:
interval = self.backoff_factor * (2 ** (current_attempt))
sleep_duration = self.jitter.add_jitter_amount(interval)
sleep_duration = self.jitter.recalculate(interval)
return sleep_duration
6 changes: 3 additions & 3 deletions slack_sdk/http_retry/jitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class Jitter:
"""Jitter interface"""

def add_jitter_amount(self, duration: float) -> float:
"""Adds a jitter amount to the given duration.
def recalculate(self, duration: float) -> float:
"""Recalculate the given duration.
see also: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
Args:
Expand All @@ -20,5 +20,5 @@ def add_jitter_amount(self, duration: float) -> float:
class RandomJitter(Jitter):
"""Random jitter implementation"""

def add_jitter_amount(self, duration: float) -> float:
def recalculate(self, duration: float) -> float:
return duration + random.random()

0 comments on commit 31d7027

Please sign in to comment.