Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Max timeout for get_ursulas/bucket_sampling; fix faulty env variable usage #77

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions porter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,25 @@ class Porter(Learner):

DEFAULT_PORT = 9155

MAX_GET_URSULAS_TIMEOUT = os.getenv("PORTER_MAX_GET_URSULAS_TIMEOUT", default=15)
MAX_BUCKET_SAMPLING_TIMEOUT = os.getenv(
"PORTER_MAX_BUCKET_SAMPLING_TIMEOUT", default=25
DEFAULT_GET_URSULAS_TIMEOUT = int(
os.getenv("PORTER_DEFAULT_GET_URSULAS_TIMEOUT", default=15)
)
MAX_DECRYPTION_TIMEOUT = os.getenv(
"PORTER_MAX_DECRYPTION_TIMEOUT",
default=ThresholdDecryptionClient.DEFAULT_DECRYPTION_TIMEOUT,
MAX_GET_URSULAS_TIMEOUT = int(
os.getenv("PORTER_MAX_GET_URSULAS_TIMEOUT", default=30)
)

DEFAULT_BUCKET_SAMPLING_TIMEOUT = int(
os.getenv("PORTER_DEFAULT_GET_URSULAS_TIMEOUT", default=25)
)
MAX_BUCKET_SAMPLING_TIMEOUT = int(
os.getenv("PORTER_MAX_BUCKET_SAMPLING_TIMEOUT", default=45)
)

MAX_DECRYPTION_TIMEOUT = int(
os.getenv(
"PORTER_MAX_DECRYPTION_TIMEOUT",
default=ThresholdDecryptionClient.DEFAULT_DECRYPTION_TIMEOUT,
)
)

_interface_class = PorterInterface
Expand Down Expand Up @@ -182,7 +194,9 @@ def get_ursulas(
min_version: Optional[str] = None,
) -> List[UrsulaInfo]:
timeout = self._configure_timeout(
"sampling", timeout, self.MAX_GET_URSULAS_TIMEOUT
"sampling",
timeout or self.DEFAULT_GET_URSULAS_TIMEOUT,
self.MAX_GET_URSULAS_TIMEOUT,
)
duration = duration or 0
parse_min_version = parse(min_version) if min_version else None
Expand Down Expand Up @@ -328,7 +342,9 @@ def bucket_sampling(
min_version: Optional[str] = None,
) -> Tuple[List[ChecksumAddress], int]:
timeout = self._configure_timeout(
"bucket_sampling", timeout, self.MAX_BUCKET_SAMPLING_TIMEOUT
"bucket_sampling",
timeout or self.DEFAULT_BUCKET_SAMPLING_TIMEOUT,
self.MAX_BUCKET_SAMPLING_TIMEOUT,
)
duration = duration or 0
parse_min_version = parse(min_version) if min_version else None
Expand Down Expand Up @@ -473,7 +489,7 @@ def make_sure_ursula_is_online(ursula_address) -> ChecksumAddress:
)

# TODO determine "best" value here without env var or parameterize
stagger_timeout = os.getenv("PORTER_STAGGER_TIMEOUT", default=1)
stagger_timeout = int(os.getenv("PORTER_STAGGER_TIMEOUT", default=1))

worker_pool = WorkerPool(
worker=make_sure_ursula_is_online,
Expand Down
Loading