diff --git a/src/python/grpcio_tests/tests/_runner.py b/src/python/grpcio_tests/tests/_runner.py index 6411ffa8981..804b1a6e331 100644 --- a/src/python/grpcio_tests/tests/_runner.py +++ b/src/python/grpcio_tests/tests/_runner.py @@ -117,7 +117,7 @@ class AugmentedCase(collections.namedtuple('AugmentedCase', ['case', 'id'])): class Runner(object): - def __init__(self, dedicated_threads=True): + def __init__(self, dedicated_threads=False): """Constructs the Runner object. Args: @@ -202,11 +202,13 @@ class Runner(object): augmented_case.case.id())) sys.stdout.flush() if self._dedicated_threads: + # (Deprecated) Spawns dedicated thread for each test case. case_thread = threading.Thread( target=augmented_case.case.run, args=(result,)) try: with stdout_pipe, stderr_pipe: case_thread.start() + # If the thread is exited unexpected, stop testing. while case_thread.is_alive(): check_kill_self() time.sleep(0) @@ -214,6 +216,7 @@ class Runner(object): except: # pylint: disable=try-except-raise # re-raise the exception after forcing the with-block to end raise + # Records the result of the test case run. result.set_output(augmented_case.case, stdout_pipe.output(), stderr_pipe.output()) sys.stdout.write(result_out.getvalue()) @@ -221,6 +224,7 @@ class Runner(object): result_out.truncate(0) check_kill_self() else: + # Donates current thread to test case execution. augmented_case.case.run(result) result.stopTestRun() stdout_pipe.close() diff --git a/src/python/grpcio_tests/tests_aio/unit/_test_server.py b/src/python/grpcio_tests/tests_aio/unit/_test_server.py index dd2d7a98ed0..5f3661f42cf 100644 --- a/src/python/grpcio_tests/tests_aio/unit/_test_server.py +++ b/src/python/grpcio_tests/tests_aio/unit/_test_server.py @@ -24,7 +24,7 @@ from src.proto.grpc.testing import test_pb2_grpc from tests.unit.framework.common import test_constants -class TestServiceServicer(test_pb2_grpc.TestServiceServicer): +class _TestServiceServicer(test_pb2_grpc.TestServiceServicer): async def UnaryCall(self, request, context): return messages_pb2.SimpleResponse() @@ -36,7 +36,7 @@ class TestServiceServicer(test_pb2_grpc.TestServiceServicer): async def start_test_server(): server = aio.server(options=(('grpc.so_reuseport', 0),)) - test_pb2_grpc.add_TestServiceServicer_to_server(TestServiceServicer(), + test_pb2_grpc.add_TestServiceServicer_to_server(_TestServiceServicer(), server) port = server.add_insecure_port('[::]:0') await server.start()