Hi,

I have a thrift client/server application written in Python (both sides). My server is supposed to send some events to the client and I'd like to use a publish/suscribe design pattern.

I think it might be possible to use the socket opened by the client from both sides and after the client opens it, it like to reuse it (sometimes later) from the server side.

Here is the code I'd like to be able to write (pseudo code):

##########################################

*thrift_client.py*

class ThriftClient:

    def connection(self):

        # 1st thread

        self.connect()

        self.suscribe()

    def receive_events(self, events)

        # Another thread called asynchronously

        self.dead_with_events(events)

#########################################

*thrift_server.py*

class ThriftServer:

    def suscribe(self):
        self.clients.add(self.current_client)

    def on_events(self, events):
          for client in self.clients:
                 client.receive_events(events)

##########################################


*service.idl*

void receive_events(list<event>)
void suscribe()

#########################################

Could someone tell me if I'm doing it the wrong way ? I know how to use one-way services or two-ways services but I don't know
if it's possible to get the client from the server.

So far I've been able to get the socket, but there is a long way to be able to call a generated method like here receive_events from just having the socket...

I'd be glad to share some code if it helps.

Thanks !

--
Julien Gréard
Jaguar Project Manager
Evitech

Reply via email to