-
Notifications
You must be signed in to change notification settings - Fork 56
Move tasks to rate-limited queue near rate-limit threshold #2941
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -118,6 +118,7 @@ def get_checkers() -> tuple[type[Checker], ...]: | |
| ) | ||
|
|
||
| def run(self) -> TaskResults: | ||
| self.check_rate_limit_remaining() | ||
|
Member
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. Wouldn't it be better to call this automatically in the parent class (
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. Ok, I didn't want to refactor to much the |
||
| # [XXX] For now cancel only when an environment variable is defined, | ||
| # should allow for less stressful testing and also optionally turning | ||
| # the cancelling on-and-off on the prod | ||
|
|
@@ -173,6 +174,7 @@ def set_logs_url(self): | |
| self.build.set_build_logs_url(copr_build_logs) | ||
|
|
||
| def run(self): | ||
| self.check_rate_limit_remaining() | ||
| run_start_time = datetime.now(timezone.utc) | ||
| if not self.build: | ||
| model = "SRPMBuildDB" if self.copr_event.chroot == COPR_SRPM_CHROOT else "CoprBuildDB" | ||
|
|
@@ -299,6 +301,7 @@ def set_built_packages(self): | |
| self.build.set_built_packages(built_packages) | ||
|
|
||
| def run(self): | ||
| self.check_rate_limit_remaining() | ||
| run_start_time = datetime.now(timezone.utc) | ||
| logger.info( | ||
| f"[CELERY_EXEC] CoprBuildEndHandler execution started for " | ||
|
|
||
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.
Using
apply_asynchere will duplicate the task when the rate limit is low, as it schedules a new task without stopping the current one. This can lead to unexpected behavior and resource consumption.To correctly re-queue the task for a later attempt, you should use
celery_task.retry(). This method raises aRetryexception that the Celery worker catches, stopping the current execution and rescheduling the task with the specified options.