cog
392819d0 - Support cancellation of concurrent tasks

Commit
1 year ago
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.
Author
Aron Carroll
Committer
Parents
Loading