From df085726731409bbae97911da772b5bee49c730e Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Sat, 31 Jul 2021 12:04:50 +0200 Subject: [PATCH] update grpc example, because grpc gevent issue has been fixed --- docs/testing-other-systems.rst | 3 --- examples/grpc/locustfile.py | 8 ++------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/docs/testing-other-systems.rst b/docs/testing-other-systems.rst index 0f9dda3ba2..b6105322a9 100644 --- a/docs/testing-other-systems.rst +++ b/docs/testing-other-systems.rst @@ -42,6 +42,3 @@ Note: In order to make the `grpcio` Python library gevent-compatible the followi import grpc.experimental.gevent as grpc_gevent grpc_gevent.init_gevent() ``` - -Note: It is important to close the gRPC channel before stopping the User greenlet; otherwise Locust may not be able to stop executing. -This is due to an issue in `grpcio` (see `grpc#15880 `_). diff --git a/examples/grpc/locustfile.py b/examples/grpc/locustfile.py index 5935e44b7d..aae17a304f 100644 --- a/examples/grpc/locustfile.py +++ b/examples/grpc/locustfile.py @@ -1,3 +1,5 @@ +# make sure you use grpc version 1.39.0 or later, +# because of https://github.com/grpc/grpc/issues/15880 that affected earlier versions import grpc import hello_pb2_grpc import hello_pb2 @@ -64,12 +66,6 @@ def __init__(self, environment): stub = self.stub_class(self._channel) self.client = GrpcClient(stub) - def stop(self, force=False): - self._channel_closed = True - time.sleep(1) - self._channel.close() - super().stop(force=True) - class HelloGrpcUser(GrpcUser): host = "localhost:50051"