From 93ef0db86b4eee95ae105f1436951e3b2f349886 Mon Sep 17 00:00:00 2001 From: Eric Gribkoff Date: Wed, 20 Feb 2019 17:11:42 -0800 Subject: [PATCH] use else in right spot --- .../grpc_health/v1/health.py | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py index dc889cdc774..15494fafdbc 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -118,15 +118,13 @@ class HealthServicer(_health_pb2_grpc.HealthServicer): status = self._server_status.get(service) if status is None: status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN # pylint: disable=no-member - else: - send_response_callback( - _health_pb2.HealthCheckResponse(status=status)) - if service not in self._send_response_callbacks: - self._send_response_callbacks[service] = set() - self._send_response_callbacks[service].add( - send_response_callback) - context.add_callback( - self._on_close_callback(send_response_callback, service)) + send_response_callback( + _health_pb2.HealthCheckResponse(status=status)) + if service not in self._send_response_callbacks: + self._send_response_callbacks[service] = set() + self._send_response_callbacks[service].add(send_response_callback) + context.add_callback( + self._on_close_callback(send_response_callback, service)) return blocking_watcher def set(self, service, status): @@ -140,12 +138,13 @@ class HealthServicer(_health_pb2_grpc.HealthServicer): with self._lock: if self._gracefully_shutting_down: return - self._server_status[service] = status - if service in self._send_response_callbacks: - for send_response_callback in self._send_response_callbacks[ - service]: - send_response_callback( - _health_pb2.HealthCheckResponse(status=status)) + else: + self._server_status[service] = status + if service in self._send_response_callbacks: + for send_response_callback in self._send_response_callbacks[ + service]: + send_response_callback( + _health_pb2.HealthCheckResponse(status=status)) def enter_graceful_shutdown(self): """Permanently sets the status of all services to NOT_SERVING.