pull/18112/head
Eric Gribkoff 6 years ago
parent fbc4ea7d8e
commit ab5b28538f
  1. 24
      src/python/grpcio_health_checking/grpc_health/v1/health.py

@ -118,13 +118,15 @@ class HealthServicer(_health_pb2_grpc.HealthServicer):
status = self._server_status.get(service) status = self._server_status.get(service)
if status is None: if status is None:
status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN # pylint: disable=no-member status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN # pylint: disable=no-member
send_response_callback( else:
_health_pb2.HealthCheckResponse(status=status)) send_response_callback(
if service not in self._send_response_callbacks: _health_pb2.HealthCheckResponse(status=status))
self._send_response_callbacks[service] = set() if service not in self._send_response_callbacks:
self._send_response_callbacks[service].add(send_response_callback) self._send_response_callbacks[service] = set()
context.add_callback( self._send_response_callbacks[service].add(
self._on_close_callback(send_response_callback, service)) send_response_callback)
context.add_callback(
self._on_close_callback(send_response_callback, service))
return blocking_watcher return blocking_watcher
def set(self, service, status): def set(self, service, status):
@ -157,6 +159,8 @@ class HealthServicer(_health_pb2_grpc.HealthServicer):
with self._lock: with self._lock:
if self._gracefully_shutting_down: if self._gracefully_shutting_down:
return return
for service in self._server_status: else:
self.set(service, _health_pb2.HealthCheckResponse.NOT_SERVING) # pylint: disable=no-member for service in self._server_status:
self._gracefully_shutting_down = True self.set(service,
_health_pb2.HealthCheckResponse.NOT_SERVING) # pylint: disable=no-member
self._gracefully_shutting_down = True

Loading…
Cancel
Save