Exemple #1
0
 def _receive_message(self):
     """
     internal coroutine that receives messages and puts
     them on the recv_queue
     """
     while True:
         if not self._ready_event.is_set():
             break
         msg_bytes = yield from self._sock.recv()
         message = validator_pb2.Message()
         message.ParseFromString(msg_bytes)
         try:
             self._futures.set_result(
                 message.correlation_id,
                 FutureResult(message_type=message.message_type,
                              content=message.content))
             self._futures.remove(message.correlation_id)
         except FutureCollectionKeyError:
             # if we are getting an initial message, not a response
             if not self._ready_event.is_set():
                 break
             self._recv_queue.put_nowait(message)
 def _make_future(self, message_type, content):
     fut = Future('test')
     fut.set_result(FutureResult(message_type=message_type,
                                 content=content))
     return fut
Exemple #3
0
 def _make_future(self, message_type, content):
     f = Future(self.context_id)
     f.set_result(FutureResult(
         message_type=message_type,
         content=content))
     return f