Exemplo n.º 1
0
 def handle(self, record: Record) -> None:
     record_type = record.WhichOneof("record_type")
     assert record_type
     handler_str = "handle_" + record_type
     handler: Callable[[Record], None] = getattr(self, handler_str, None)
     assert handler, "unknown handle: {}".format(handler_str)
     handler(record)
Exemplo n.º 2
0
    def send_and_receive(self, rec: pb.Record, local: Optional[bool] = None) -> _Future:
        rec.control.req_resp = True
        if local:
            rec.control.local = local
        rec.uuid = uuid.uuid4().hex
        future = _Future()
        with self._lock:
            self._pending_reqs[rec.uuid] = future

        self._request_queue.put(rec)

        return future