Exemple #1
0
 def send(self, destination, request, **any):
     """
     Send the request then read the reply.
     @param destination: The destination queue address.
     @type destination: str
     @param request: A request to send.
     @type request: object
     @keyword any: Any (extra) data.
     @return: The result of the request.
     @rtype: object
     @raise Exception: returned by the peer.
     """
     sn = self.producer.send(
         destination,
         ttl=self.timeout[0],
         replyto=str(self.queue),
         request=request,
         **any)
     log.info('sent (%s):\n%s', repr(destination), request)
     reader = Reader(self.queue, url=self.producer.url)
     reader.open()
     try:
         self.__getstarted(sn, reader)
         return self.__getreply(sn, reader)
     finally:
         reader.close()
Exemple #2
0
 def accepted(self, sock):
     uuid = toq(getuuid())
     p = Producer(url=self.url)
     p.send(toq(self.peer), peer=str(uuid))
     r = Reader(uuid, url=self.url)
     env = r.next()
     tr = TunnelReader(r, sock)
     tr.start()
     tw = TunnelWriter(self.url, env.peer, sock)
     tw.start()