-
Notifications
You must be signed in to change notification settings - Fork 34
Improve backoff #1920
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
Improve backoff #1920
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,10 +81,16 @@ async def refresh_listener(invocation: Mapping[str, Any]) -> None: | |
| retry_on_auth_error = backoff.on_exception( | ||
| backoff.expo, | ||
| (NotAuthenticatedException, ServerDisconnectedError, ClientConnectorError), | ||
| max_tries=2, | ||
| max_tries=5, | ||
| on_backoff=relogin, | ||
| ) | ||
|
|
||
| retry_on_connection_failure = backoff.on_exception( | ||
| backoff.expo, | ||
| (TimeoutError, ClientConnectorError), | ||
| max_tries=10, | ||
| ) | ||
|
|
||
| retry_on_concurrent_requests = backoff.on_exception( | ||
| backoff.expo, | ||
| TooManyConcurrentRequestsException, | ||
|
|
@@ -97,6 +103,12 @@ async def refresh_listener(invocation: Mapping[str, Any]) -> None: | |
| max_tries=10, | ||
| ) | ||
|
|
||
| retry_on_execution_queue_full = backoff.on_exception( | ||
| backoff.expo, | ||
| ExecutionQueueFullException, | ||
| max_tries=5, | ||
| ) | ||
|
|
||
| retry_on_listener_error = backoff.on_exception( | ||
| backoff.expo, | ||
| (InvalidEventListenerIdException, NoRegisteredEventListenerException), | ||
|
|
@@ -414,6 +426,7 @@ async def register_event_listener(self) -> str: | |
| @retry_on_concurrent_requests | ||
| @retry_on_auth_error | ||
| @retry_on_listener_error | ||
| @retry_on_connection_failure | ||
| async def fetch_events(self) -> list[Event]: | ||
|
Comment on lines
426
to
430
|
||
| """Fetch new events from a registered event listener. Fetched events are removed. | ||
|
|
||
|
|
@@ -460,6 +473,7 @@ async def get_api_version(self) -> str: | |
| return cast(str, response["protocolVersion"]) | ||
|
|
||
| @retry_on_too_many_executions | ||
| @retry_on_execution_queue_full | ||
| @retry_on_auth_error | ||
|
Comment on lines
475
to
477
|
||
| async def _execute_action_group_direct( | ||
| self, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClientConnectorErroris included in bothretry_on_auth_errorand the newretry_on_connection_failure. When both decorators are applied (e.g.,fetch_events), retries become nested/multiplicative (up to 5 * 10 attempts) andreloginmay run for pure connection failures. Consider making the exception sets disjoint (e.g., removeClientConnectorErrorfromretry_on_auth_errorand handle it only viaretry_on_connection_failure) so connection outages don't trigger re-auth and total retry budget is predictable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed