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

Implements $cancel() method for ExtendedTask #4199

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shikokuchuo
Copy link
Member

Closes #4093.

Adds a $cancel() method to ExtendedTask, analogous to the python implementation.

This keeps it simple, and is straightforward as the do.call() in the code creates the task object anyway, and we just need to store it in a private field.

Previously I'd thought that the promise itself might have a $cancel method, but looking at javascript promises, this actually doesn't exist. It's also not natural to implement it that way, as promises::promise() takes functions as arguments, rather than the task object itself. We'd most likely need to rely on each as.promise() method to create this.

We could make cancellation extendable via a S3 generic for the task object for example, but as mirai is the only known implementation with cancellation capability thus far, we might defer this.

@shikokuchuo
Copy link
Member Author

Adding to the documentation example - you can see that the current cancellation behaviour (at mirai) is very explicit in causing the promise to be rejected. This was thought to be the 'safest' behaviour, in case it needs to be logged etc.

An alternative would be for cancellation to fail silently, as in the interrupt case.

@shikokuchuo
Copy link
Member Author

This keeps it simple, and is straightforward as the do.call() in the code creates the task object anyway, and we just need to store it in a private field.

Need to think more on the implementation, as this task object could already be a promise e.g. if the user adds their own $then() logic within the ExtendedTask initializer. Perhaps there's no easy solution to this.

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.

ExtendedTasks: how to kill a task?
1 participant