Skip to content

Commit

Permalink
Merge pull request #1834 from locustio/grpc-gevent-issue-has-been-fixed
Browse files Browse the repository at this point in the history
update grpc example, because grpc gevent issue has been fixed
  • Loading branch information
cyberw authored Aug 1, 2021
2 parents 29242c9 + df08572 commit 975d3aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
3 changes: 0 additions & 3 deletions docs/testing-other-systems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/grpc/grpc/issues/15880>`_).
8 changes: 2 additions & 6 deletions examples/grpc/locustfile.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 975d3aa

Please sign in to comment.