Description
It took me a while to think about the different scenarios to conclude calling cancel only when CancelledError
is raised. Just to confirm my thinking is correct, you do this because if any other unexpected exception is raised and _run()
is aborted, the auto-restart for actors will kick-in and meanwhile, any task that it is still healthy, will continue working, so hopefully ready dispatches will still be delivered on time, even if the actor wasn't restarted yet?
If this is the case, maybe you should check tasks health when _fetch()
ing too, in case some task was aborted, to try to restart it. Right now you are only checking if a task is in the _scheduled
dict, but not if the tasks are still running or not.
In any case, it is probably worth adding a comment here clarifying how clean up works exactly on different scenarios.
Originally posted by @llucax in #9 (comment)