Ejemplo n.º 1
0
 def dispatch(self, call):
     """
     Dispatch the call to the handler.
     :param call: A *call* document.
     :type call: Document
     """
     reply = Document()
     try:
         method = getattr(self.handler, call.name)
         result = method(*call.args, **call.kwargs)
         reply.code = 0
         reply.result = result
     except Exception as e:
         reply.code = 1
         reply.result = str(e)
     return reply.dump()
Ejemplo n.º 2
0
 def dispatch(self, call):
     """
     Dispatch the call to the handler.
     :param call: A *call* document.
     :type call: Document
     """
     reply = Document()
     try:
         method = getattr(self.handler, call.name)
         result = method(*call.args, **call.kwargs)
         reply.code = 0
         reply.result = result
     except Exception as e:
         reply.code = 1
         reply.result = str(e)
     return reply.dump()
Ejemplo n.º 3
0
 def call(self, *args, **kwargs):
     """
     Remote call.
     """
     socket = Socket(AF_INET, SOCK_STREAM)
     socket.connect(self.address)
     try:
         method = Document()
         method.name = self.name
         method.args = args
         method.kwargs = kwargs
         socket.send(method.dump())
         reply = socket.recv(4096)
         result = Document()
         result.load(reply)
         return result
     finally:
         socket.close()
Ejemplo n.º 4
0
 def call(self, *args, **kwargs):
     """
     Remote call.
     """
     socket = Socket(AF_INET, SOCK_STREAM)
     socket.connect(self.address)
     try:
         method = Document()
         method.name = self.name
         method.args = args
         method.kwargs = kwargs
         socket.send(method.dump())
         reply = socket.recv(4096)
         result = Document()
         result.load(reply)
         return result
     finally:
         socket.close()