From d43ac68bf3f2807918cc0556bddb2251a1483e73 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 16 Mar 2020 15:48:08 -0700 Subject: [PATCH] Make the empty service default to SERVING state --- src/python/grpcio_health_checking/grpc_health/v1/_async.py | 2 +- src/python/grpcio_health_checking/grpc_health/v1/health.py | 2 +- .../grpcio_tests/tests/health_check/_health_servicer_test.py | 1 - .../grpcio_tests/tests_aio/health_check/health_servicer_test.py | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/python/grpcio_health_checking/grpc_health/v1/_async.py b/src/python/grpcio_health_checking/grpc_health/v1/_async.py index 859cadbd642..752531f5171 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/_async.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/_async.py @@ -30,7 +30,7 @@ class HealthServicer(_health_pb2_grpc.HealthServicer): _gracefully_shutting_down: bool def __init__(self) -> None: - self._server_status = dict() + self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING} self._server_watchers = collections.defaultdict(asyncio.Condition) self._gracefully_shutting_down = False 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 05a16c73380..f7ee639ec8a 100644 --- a/src/python/grpcio_health_checking/grpc_health/v1/health.py +++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py @@ -85,7 +85,7 @@ class HealthServicer(_health_pb2_grpc.HealthServicer): experimental_non_blocking=True, experimental_thread_pool=None): self._lock = threading.RLock() - self._server_status = {} + self._server_status = {"": _health_pb2.HealthCheckResponse.SERVING} self._send_response_callbacks = {} self.Watch.__func__.experimental_non_blocking = experimental_non_blocking self.Watch.__func__.experimental_thread_pool = experimental_thread_pool diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py index b782d80e639..01345aaca08 100644 --- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py +++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py @@ -50,7 +50,6 @@ class BaseWatchTests(object): self._servicer = health.HealthServicer( experimental_non_blocking=non_blocking, experimental_thread_pool=thread_pool) - self._servicer.set('', health_pb2.HealthCheckResponse.SERVING) self._servicer.set(_SERVING_SERVICE, health_pb2.HealthCheckResponse.SERVING) self._servicer.set(_UNKNOWN_SERVICE, diff --git a/src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py b/src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py index 71166a2beff..ac6c84b2f54 100644 --- a/src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py +++ b/src/python/grpcio_tests/tests_aio/health_check/health_servicer_test.py @@ -47,8 +47,6 @@ class HealthServicerTest(AioTestBase): async def setUp(self): self._servicer = health.aio.HealthServicer() - await self._servicer.set(health.OVERALL_HEALTH, - health_pb2.HealthCheckResponse.SERVING) await self._servicer.set(_SERVING_SERVICE, health_pb2.HealthCheckResponse.SERVING) await self._servicer.set(_UNKNOWN_SERVICE,