-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allow passing function refs to Portal.run() ? #69
Comments
Probably want to go with a separate method names here? Better to be explicit. Another option is for this to be the default, and have a Something like: So you could reference/run classmethods or staticmethods in a sub-namespace inside a module. And it's explicit / the caller knows what is going on. |
This is to address the request from a couple people for the ability to not have to specify the explicit module path for a callable to be invoked in a remote actor when the desired function is defined locally. This makes the API to run a local func look more like `trio.Nurser.start_soon(my_func, *args)` which is simpler and much more "shorthand". In this case we simply introspect the function/callable object and send that info to the remote actor to be *looked up locally* and scheduled. Resolves #69
This is to address the request from a couple people for the ability to not have to specify the explicit module path for a callable to be invoked in a remote actor when the desired function is defined locally. This makes the API to run a local func look more like `trio.Nurser.start_soon(my_func, *args)` which is simpler and much more "shorthand". In this case we simply introspect the function/callable object and send that info to the remote actor to be *looked up locally* and scheduled. Resolves #69
Quoting @ryanhiebert here from his comment in #105:
RE trio across machines (and processes) is a big 👍. I think I actually agree with
now after thinking about this more. i previously had a hazy version of what an inter-actor comms API looked like for multi-host setups and I think what I was thinking is wrong. More on this later.
I'd even go further that the API for calling code and starting tasks must be explicitly different then the current
I actually think now after thinking about remote (host) actor spawning that a
that they need to be so differentiated.
I would almost prefer this type of RPC/script injection is something that
Understood.
As mentioned the more I think on it
Fair, the
👌 |
@ryanhiebert I think you're going to get your wish on this one. After thinking it through I can't think of a reason to not encourage passing func references to these methods and any inter-host rpc system will need to be built on top of this regardless. This will land before #104. |
This resolves and completes #69 allowing all RPC invocation APIs to pass function references directly instead of explicit `str` names for the target namespace and function (this is still done implicitly underneath). This brings us closer to `trio`'s task running API as well as acknowledges that any inter-host RPC system (and API) will likely need to be implemented on top of local RPC primitives anyway. Even if this ends up **not** being true we can always go to "function stubs" as part of our IAC protocol or, add a new method to do explicit namespace calls: `.run_from_module()` or whatever everyone votes on. Resolves #69 Further, this commit drops `Actor.statespace` from the entire system since a user can easily get this same functionality using module level variables. Fix docs to match all these changes (luckily mostly already done due to example scripts referencing).
@parity3 had the same thought as I: why can't
Portal.run()
accept a direct function reference and then we simply lookup the functions module and name much like we do inActorNursery.run_in_actor()
? This would of course have the implicit assumption that the remote actor has the chosen function's module code loaded for use.The only question is really how to expose both ways on
Portal
?run_func()
?func
orref
kwarg?Portal.run()
to be either a module name or a func ref and then in the named case makename
a required kwarg?The text was updated successfully, but these errors were encountered: