Skip to content

Commit

Permalink
Merge pull request #77 from derekpierre/max-timeout
Browse files Browse the repository at this point in the history
Increase Max timeout for `get_ursulas`/`bucket_sampling`; fix faulty env variable usage
  • Loading branch information
derekpierre authored Sep 10, 2024
2 parents d540b7c + 8224acc commit e1b0550
Showing 1 changed file with 25 additions and 9 deletions.
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

0 comments on commit e1b0550

Please sign in to comment.