Re: Can I register a function (not a class) ?
Irmen de Jong <[email protected]> Fri, 18 Oct 2013 23:51:32 +0200
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
On 18-10-2013 23:03, Richard van Bemmelen wrote:
> Since in Python everything is an object, I thought this would be possible to but it does
> not work.
>
> Richard
>
Not sure what you're trying to accomplish, but this (silly) example does work:
import Pyro4
def func(arg):
return arg*arg
func.foo = lambda x: x+x
Pyro4.Daemon.serveSimple({
func: "thing"
}, ns=False)
Notice though that because you expose the function object itself through Pyro, any
remote method call performed on the proxy for it will translate in a "method" call on
the fuction object, rather than a direct invocation of the function itself.
You cannot do a direct call on the proxy such as: proxy(55), because the Pyro proxy is
not a callable right now. I guess that could be added in a future version.
In the meantime, make your function a member of a class and register the class with
Pyro. Then call your function as a remote method on the proxy for it.
Irmen
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk