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

Cross-actor cancel scopes? #122

Open
goodboy opened this issue Jul 9, 2020 · 1 comment
Open

Cross-actor cancel scopes? #122

goodboy opened this issue Jul 9, 2020 · 1 comment
Labels
cancellation SC teardown semantics and anti-zombie semantics supervision

Comments

@goodboy
Copy link
Owner

goodboy commented Jul 9, 2020

I was just trying to psuedo complete #36 for a collaborator and realized we don't have a way to cancel a task arbitrarily started from the calling actor.

This should be possible in theory by creating our own version of trio.CancelScope that is aware of tasks started by Portal.run(). I don't think anything more is needed other then that since ActorNursery.run_in_actor() main tasks should in theory be solo and cancelled when the actor terminates (which happens when the nursery exits).

One question is whether we should add a new 'cancel' message to the in-progress iac protocol.

Right now you can use the existing "rpc" mechanisms to call a cancel method on the remote Actor (specifically ._cancle_task()), but this is likely too tightly coupled to tractor's specific implementation in the case where we want to support other languages which can interact in an SC way with tractor systems using this same protocol.

@goodboy
Copy link
Owner Author

goodboy commented Oct 22, 2021

This is somewhat implemented with our new ContextCancelled style signalling in the Portal.open_context() api.

Work in https://github.com/goodboy/tractor/tree/zombie_lord_infinite also starts trying to apply the task-contexts stuff to regular rpc calls, and eventually we should probably implement all invocation apis this way (Portal.run(), Portal.open_stream_from()). I've actually been thinking we could also return a cancel scope like object from some of these calls:

async with tractor.open_nursery() as n:
   portal, context = await n.run_in_actor(blah)
   
   # stuff
   
   # this waits on the top level task for a result
   await context.result()

@goodboy goodboy added cancellation SC teardown semantics and anti-zombie semantics supervision labels Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cancellation SC teardown semantics and anti-zombie semantics supervision
Projects
None yet
Development

No branches or pull requests

1 participant