Further simplify the loop

pull/22028/head
Lidi Zheng 5 years ago
parent 545f312050
commit fe4eba490c
  1. 19
      src/python/grpcio_health_checking/grpc_health/v1/_async.py

@ -43,18 +43,13 @@ class AsyncHealthServicer(_health_pb2_grpc.HealthServicer):
try: try:
async with condition: async with condition:
while True: while True:
status = self._server_status.get(request.service) status = self._server_status.get(
request.service,
if status: _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN)
# Responds with current health state
await context.write( # Responds with current health state
_health_pb2.HealthCheckResponse(status=status)) await context.write(
else: _health_pb2.HealthCheckResponse(status=status))
# Responds with default value
await context.write(
_health_pb2.HealthCheckResponse(
status=_health_pb2.HealthCheckResponse.
SERVICE_UNKNOWN))
# Polling on health state changes # Polling on health state changes
await condition.wait() await condition.wait()

Loading…
Cancel
Save