async def call_rpc(self, rpc_message: RpcMessage, options: dict, bus_client: "BusClient"): queue_key = f"{rpc_message.api_name}:rpc_queue" expiry_key = f"rpc_expiry_key:{rpc_message.id}" logger.debug( LBullets( L("Enqueuing message {} in Redis list {}", Bold(rpc_message), Bold(queue_key)), items=dict(**rpc_message.get_metadata(), kwargs=rpc_message.get_kwargs()), )) start_time = time.time() for try_number in range(3, 0, -1): last_try = try_number == 1 try: await self._call_rpc(rpc_message, queue_key, expiry_key) return except (PipelineError, ConnectionClosedError, ConnectionResetError): if not last_try: await asyncio.sleep(self.rpc_retry_delay) else: raise logger.debug( L( "Enqueued message {} in Redis in {} stream {}", Bold(rpc_message), human_time(time.time() - start_time), Bold(queue_key), ))
async def call_rpc(self, rpc_message: RpcMessage, options: dict): queue_key = f"{rpc_message.api_name}:rpc_queue" expiry_key = f"rpc_expiry_key:{rpc_message.id}" logger.debug( LBullets( L("Enqueuing message {} in Redis stream {}", Bold(rpc_message), Bold(queue_key)), items=dict(**rpc_message.get_metadata(), kwargs=rpc_message.get_kwargs()), )) with await self.connection_manager() as redis: start_time = time.time() print("setting " + expiry_key) p = redis.pipeline() p.rpush(key=queue_key, value=self.serializer(rpc_message)) p.set(expiry_key, 1) p.expire(expiry_key, timeout=self.rpc_timeout) await p.execute() logger.debug( L( "Enqueued message {} in Redis in {} stream {}", Bold(rpc_message), human_time(time.time() - start_time), Bold(queue_key), ))