-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some more ergonomics to instance syncing along with sqlite example (
- Loading branch information
1 parent
c43e55b
commit 097177f
Showing
9 changed files
with
382 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from __future__ import annotations | ||
|
||
__version__ = "6.21.1" | ||
__version__ = "6.22.0" | ||
__api_subversion__ = "V20220125" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from __future__ import annotations | ||
|
||
from random import uniform | ||
from typing import Iterator | ||
|
||
|
||
class Backoff(Iterator[float]): | ||
"""Iterator that emits how long to wait, according to the "Full Jitter" approach | ||
described in this post: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ | ||
Args: | ||
multiplier (float): No description. | ||
max_wait (float): No description. | ||
base (int): No description.""" | ||
|
||
def __init__(self, multiplier: float = 0.5, max_wait: float = 60.0, base: int = 2) -> None: | ||
self._multiplier = multiplier | ||
self._max_wait = max_wait | ||
self._base = base | ||
self._past_attempts = 0 | ||
|
||
def __next__(self) -> float: | ||
# 100 is an arbitrary limit at which point most sensible parameters are likely to | ||
# be capped by max anyway. | ||
wait = uniform(0, min(self._multiplier * (self._base ** min(100, self._past_attempts)), self._max_wait)) | ||
self._past_attempts += 1 | ||
return wait | ||
|
||
def reset(self) -> None: | ||
self._past_attempts = 0 | ||
|
||
def has_progressed(self) -> bool: | ||
return self._past_attempts > 0 |
Oops, something went wrong.