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

Example about how to kill a running task #7031

Closed
wants to merge 1 commit into from
Closed

Conversation

humitos
Copy link
Member

@humitos humitos commented May 6, 2020

⚠️ DO NOT MERGE ⚠️

This PR is an example of how to cancel an already triggered build.

From what I've seen, it would be good to implement #3984 before working on a solution to cancel builds. Or, implement only the part needed for now to handle the BuildKilled exception.

I think implementing that issue first is better because otherwise, we need to handle the exception BuildKilled in many different places inside the code of the task itself:

  • environment context manager
  • all the methods that are ran inside the task itself

The current implementation "works", but it's not handling the exception in all the places needed. So, depending when you click on "Cancel build" you will get a gracefully killed build (proper set of all the attributes --success=False, etc) or a hard killed build.

@humitos humitos requested a review from ericholscher May 6, 2020 16:29
@humitos humitos mentioned this pull request Jun 2, 2020
@humitos
Copy link
Member Author

humitos commented Jun 8, 2020

We are de-duplicating builds for now, only. Not cancelling already running builds.

@humitos humitos closed this Jun 8, 2020
@stsewd stsewd deleted the humitos/revoke-tasks branch May 24, 2021 18:25
humitos added a commit that referenced this pull request Jan 26, 2022
We tried to implement this in another opportunities (see
#7031) but the build process
was really complex and we had to manage the exception in multiple places.

After implementing Celery Handlers, we can just raise the exception when
attending to the proper signal coming from `app.control.revoke` and handle it
properly from `on_failure` task's method.

All the initial local tests were great!
humitos added a commit that referenced this pull request Feb 22, 2022
We tried to implement this in another opportunities (see
#7031) but the build process
was really complex and we had to manage the exception in multiple places.

After implementing Celery Handlers, we can just raise the exception when
attending to the proper signal coming from `app.control.revoke` and handle it
properly from `on_failure` task's method.

All the initial local tests were great!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant