-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support cancellation of concurrent tasks
Currently a cancellation event sent to a worker with `concurrency` > 1 will always cancel the most recent task. This commit refactors the `_ChildWorker` class to exclusively send the `Cancel` event when receiving a `CancelRequest` and then handle the cancellation in the event loop. For the async `_aloop` we now use a weak map to track all in flight prediction tasks. On cancel, we retrieve the task from the map and cancel it. For the standard `_loop` method we send the cancellation signal to the process as before. It's not entirely clear why the child needs to send the signal to itself vs raising the `CancellationException` directly but this commit leaves it as-is for simplicity.
- Loading branch information
Showing
2 changed files
with
115 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters