[Twisted-Python] Perspective Broker vs AMP
Hi, You may have seen my recent posts about data comms across nodes of server network. Phil kindly pointed me towards PB and AMP which, after some fiddling both look viable. However, I do have one question: If clients can request remote data from the server, is the reverse possible? As I understand PB, a client can get the root object of a PBServerFactory, thru which it can call methods with the 'remote_' prefix. I'm not clear how this can work in the other direction. As for AMP, this seems similar - the client uses callRemote() to execute remote methods on the amp server. Since I have node clients all talking through a server, I need the client to make requests to the server, which in turn requests the appropriate data from the corresponding client. Thanks for any advice on this Regards Simon -- Linux Counter: User# 424693
Simon Pickles wrote:
Hi,
You may have seen my recent posts about data comms across nodes of server network.
Phil kindly pointed me towards PB and AMP which, after some fiddling both look viable. However, I do have one question: If clients can request remote data from the server, is the reverse possible?
As I understand PB, a client can get the root object of a PBServerFactory, thru which it can call methods with the 'remote_' prefix. I'm not clear how this can work in the other direction. As for
Well, this is a contrived example (since you could just return the deferred) but: class Server(pb.Referenceable): def remote_foo(self, client): d = doThing().addCallback(self.thing_result, client) def thing_result(self, result, client): client.callRemote('thing', result) class Client(pb.Referenceable): def remote_thing(self, thing): # do something def callServer(self): d = self.server.getRootObject().addCallback(self.callServer2) def callServer2(self, server): server.callRemote('foo', self) That is - when you callRemote() you can pass pb.Referenceable as arguments, and the other end call callRemote on those objects.
AMP, this seems similar - the client uses callRemote() to execute remote methods on the amp server.
No idea about AMP
Since I have node clients all talking through a server, I need the client to make requests to the server, which in turn requests the appropriate data from the corresponding client.
Thanks for any advice on this
Regards
Simon
On Mon, Mar 31, 2008 at 6:55 AM, Phil Mayers <p.mayers@imperial.ac.uk> wrote:
Simon Pickles wrote:
Hi,
You may have seen my recent posts about data comms across nodes of server network.
Phil kindly pointed me towards PB and AMP which, after some fiddling both look viable. However, I do have one question: If clients can request remote data from the server, is the reverse possible?
As I understand PB, a client can get the root object of a PBServerFactory, thru which it can call methods with the 'remote_' prefix. I'm not clear how this can work in the other direction. As for
Well, this is a contrived example (since you could just return the deferred) but:
class Server(pb.Referenceable): def remote_foo(self, client): d = doThing().addCallback(self.thing_result, client)
def thing_result(self, result, client): client.callRemote('thing', result)
class Client(pb.Referenceable): def remote_thing(self, thing): # do something
def callServer(self): d = self.server.getRootObject().addCallback(self.callServer2) def callServer2(self, server): server.callRemote('foo', self)
That is - when you callRemote() you can pass pb.Referenceable as arguments, and the other end call callRemote on those objects.
AMP, this seems similar - the client uses callRemote() to execute remote methods on the amp server.
No idea about AMP
AMP is bidirectional as well. The server uses callRemote to communicate with the connected client(s): http://djfroofy.livejournal.com/3509.html -- \\\\\/\"/\\\\\\\\\\\ \\\\/ // //\/\\\\\\\ \\\/ \\// /\ \/\\\\ \\/ /\/ / /\/ /\ \\\ \/ / /\/ /\ /\\\ \\ / /\\\ /\\\ \\\\\/\ \/\\\\\/\\\\\/\\\\\\ d.p.s
On Mon, 31 Mar 2008 09:00:40 +0100, Simon Pickles <sipickles@hotmail.com> wrote:
Hi,
You may have seen my recent posts about data comms across nodes of server network.
Phil kindly pointed me towards PB and AMP which, after some fiddling both look viable. However, I do have one question: If clients can request remote data from the server, is the reverse possible?
As I understand PB, a client can get the root object of a PBServerFactory, thru which it can call methods with the 'remote_' prefix. I'm not clear how this can work in the other direction. As for AMP, this seems similar - the client uses callRemote() to execute remote methods on the amp server.
Since I have node clients all talking through a server, I need the client to make requests to the server, which in turn requests the appropriate data from the corresponding client.
Thanks for any advice on this
In addition to the other suggestions that have been made in this thread, notice that PBClientFactory.login takes two arguments: the credentials object used for authentication and an optional "client" object which defaults to None. The value of this parameter is made available to your realm in the `mind´ parameter. This means you can pass a reference to login for this parameter and the server can use it to make calls onto the client whenever it wants, rather than having to wait for a subsequent call made by the client. Jean-Paul
Jean-Paul Calderone wrote:
On Mon, 31 Mar 2008 09:00:40 +0100, Simon Pickles <sipickles@hotmail.com> wrote:
Hi,
You may have seen my recent posts about data comms across nodes of server network.
Phil kindly pointed me towards PB and AMP which, after some fiddling both look viable. However, I do have one question: If clients can request remote data from the server, is the reverse possible?
As I understand PB, a client can get the root object of a PBServerFactory, thru which it can call methods with the 'remote_' prefix. I'm not clear how this can work in the other direction. As for AMP, this seems similar - the client uses callRemote() to execute remote methods on the amp server.
Since I have node clients all talking through a server, I need the client to make requests to the server, which in turn requests the appropriate data from the corresponding client.
Thanks for any advice on this
In addition to the other suggestions that have been made in this thread, notice that PBClientFactory.login takes two arguments: the credentials object used for authentication and an optional "client" object which defaults to None.
This looks very interesting.
The value of this parameter is made available to your realm in the `mind´ parameter.
Er, I'm sorry but I don't understand realm and mind. I'm new to this area.
This means you can pass a reference to login for this parameter and the server can use it to make calls onto the client whenever it wants, rather than having to wait for a subsequent call made by the client.
This is exactly what I would like to do. Simon -- Linux Counter: User# 424693
On Mon, 31 Mar 2008 13:18:44 +0100, Simon Pickles <sipickles@hotmail.com> wrote:
Jean-Paul Calderone wrote: [snip]
In addition to the other suggestions that have been made in this thread, notice that PBClientFactory.login takes two arguments: the credentials object used for authentication and an optional "client" object which defaults to None.
This looks very interesting.
The value of this parameter is made available to your realm in the `mind´ parameter.
Er, I'm sorry but I don't understand realm and mind. I'm new to this area.
This means you can pass a reference to login for this parameter and the server can use it to make calls onto the client whenever it wants, rather than having to wait for a subsequent call made by the client.
This is exactly what I would like to do.
Have you read the cred howto? There is a section on realms and one on minds (although the mind section is quite abstract and may not make any sense). http://twistedmatrix.com/projects/core/documentation/howto/cred.html Basically, the mind is just an argument which will be available in your realm to use however you like. The realm is the object which creates your avatars. Avatars are the objects which are returned by the login method of PBClientFactory. Jean-Paul
participants (4)
-
Drew Smathers -
Jean-Paul Calderone -
Phil Mayers -
Simon Pickles