Re: Can I register a function (not a class) ?

Richard van Bemmelen <[email protected]> Sat, 19 Oct 2013 00:18:41 +0200
Newsgroups gmane.comp.python.pyro
Message-ID <CAMEWXj2TAed6rV0kVN9QYcQnm2WFOiBT3dtDF+La11-2jD_VuA@mail.gmail.com>
It was meant for a debug server/client situation, like:

def deb(any, debvars=[]):
nowt = '\n++++ ' + getnow()
# get name of function that called me
name = ', function : ' + inspect.stack()[1][3]
vars = [nowt + name]
        etc

I do not think this will work form a class.
It sort of worked with sockets, but too much trouble, so I thought maybe
Pyro could be used here.

Richard

Richard



2013/10/18 Irmen de Jong <[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
> _______________________________________________
> Pyro-core mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyro-core
>

------------------------------------------------------------------------------
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

_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core