1

My retry policy is defined as

options = []
retry_policy = {
    "methodConfig": [{
    "name": [{"service": ""}],
    "retryPolicy": {
    "maxAttempts": 3,
    "initialBackoff": "1s",
    "maxBackoff": "10s",
    "backoffMultiplier": 2,
    "retryableStatusCodes": ["UNAVAILABLE","DEADLINE_EXCEEDED"],
    "timeout" : "10s",
    "waitForReady": True
   }
  }]
}
options.append(("grpc.service_config", json.dumps(retry_policy)))

    channel = grpc.secure_channel(target=cls.get_host() + ':' + str(cls.get_port()),
    credentials=cls._get_client_credentials(),
    options=options)

    return channel

Then my client is using this channel to make a grpc call

response = ScheduleNanoserviceStub(cls.get_channel()).cancel(request=request,                                                                                             metadata=cls.to_metadata(user_claims))

In my gRPC server, I am putting a time.sleep() for 30 seconds

def cancel(self, request: ResourceScheduleReservationRequest, context, claims: Claims) ->  ResourceScheduleFlightResponse:     
    reservation_uuid: str = request.reservation_uuid     
    print(time.time())    
    time.sleep(30)     
    context.abort(StatusCode.UNAVAILABLE, "testing gRPC timeout")    
    try:        
    **some-valid-code**

My expectation was, since the server does not respond within the timeout 10s, the request is retried, but the retry is happening after 30 seconds instead of 10. Can someone please help me out?

I have a query with python retry_policy and I'm stuck`

1 Answers1

0

Retry policy does not have a timeout setting (specification)

This post seems to provide a working example: Configuring retry policy for grpc request

Eugene
  • 9,242
  • 2
  • 30
  • 29