-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(taskbroker): Clarify docstring & class name #103893
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
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 |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
|
|
||
| from sentry.taskworker.constants import CompressionType | ||
| from sentry.taskworker.registry import TaskNamespace | ||
| from sentry.taskworker.retry import Retry, RetryError, retry_task | ||
| from sentry.taskworker.retry import Retry, RetryTaskError, retry_task | ||
| from sentry.taskworker.state import current_task | ||
| from sentry.taskworker.task import P, R, Task | ||
| from sentry.taskworker.workerchild import ProcessingDeadlineExceeded | ||
|
|
@@ -123,10 +123,24 @@ def retry( | |
| >>> def my_task(): | ||
| >>> ... | ||
|
|
||
| If timeouts is True, task timeout exceptions will trigger a retry. | ||
| If it is False, timeout exceptions will behave as specified by the other parameters. | ||
| """ | ||
| The first set of parameters define how different exceptions are handled. | ||
| Raising an error will still report a Sentry event. | ||
|
|
||
| | Parameter | Retry | Report | Raise | Description | | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| |--------------------|-------|--------|-------|-------------| | ||
| | on | Yes | Yes | No | Exceptions that will trigger a retry & report to Sentry. | | ||
| | on_silent | Yes | No | No | Exceptions that will trigger a retry but not be captured to Sentry. | | ||
| | exclude | No | No | Yes | Exceptions that will not trigger a retry and will be raised. | | ||
| | ignore | No | No | No | Exceptions that will be ignored and not trigger a retry & not report to Sentry. | | ||
| | ignore_and_capture | No | Yes | No | Exceptions that will not trigger a retry and will be captured to Sentry. | | ||
|
|
||
| The following modifiers modify the behavior of the retry decorator. | ||
|
|
||
| | Modifier | Description | | ||
| |------------------------|-------------| | ||
| | timeouts | ProcessingDeadlineExceeded trigger a retry. | | ||
| | raise_on_no_retries | Makes a RetryTaskError not be raised if no retries are left. | | ||
| """ | ||
| if func: | ||
| return retry()(func) | ||
|
|
||
|
|
@@ -138,18 +152,16 @@ def retry( | |
| def inner(func): | ||
| @functools.wraps(func) | ||
| def wrapped(*args, **kwargs): | ||
| task_state = current_task() | ||
| no_retries_remaining = task_state and not task_state.retries_remaining | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Putting these variables here is to simplify a follow-up PR I have. |
||
| try: | ||
| return func(*args, **kwargs) | ||
| except ignore: | ||
| return | ||
| except RetryError: | ||
| if ( | ||
| not raise_on_no_retries | ||
| and (task_state := current_task()) | ||
| and not task_state.retries_remaining | ||
| ): | ||
| except RetryTaskError: | ||
| if not raise_on_no_retries and no_retries_remaining: | ||
| return | ||
| # If we haven't been asked to ignore no-retries, pass along the RetryError. | ||
| # If we haven't been asked to ignore no-retries, pass along the RetryTaskError. | ||
| raise | ||
| except timeout_exceptions: | ||
| if timeouts: | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From here on, there's only renaming of the variable across the codebase. |

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.
Renaming the variable name makes it easier to search for this.