question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GRPC compatibility : Locust load test throws greenlet.GreenletExit exception on reaching test time limit

See original GitHub issue

Describe the bug

Locust load test throws greenlet.GreenletExit exception on reaching test time limit while testing GRPC based services. To monkey patch GRPC with gevent I am using grpc’s:

import grpc.experimental.gevent as grpc_gevent
grpc_gevent.init_gevent()

but no luck.

Expected behavior

Should gracefully stop all greenlets and generate the necessary outputs.

Actual behavior

Test keeps on generating load, does not stop, has to be stopped via CTRL+C Keyboard Interrupt. Thrown exception:

[2021-01-18 13:40:47,715] C02CD0BNMD6N/INFO/locust.main: Run time limit set to 30 seconds
[2021-01-18 13:40:47,715] C02CD0BNMD6N/INFO/locust.main: Starting Locust 1.4.1
[2021-01-18 13:40:47,716] C02CD0BNMD6N/DEBUG/locust.runners: Updating state to 'spawning', old state was 'ready'
[2021-01-18 13:40:47,716] C02CD0BNMD6N/INFO/locust.runners: Spawning 5 users at the rate 3 users/s (0 users already running)...

 a bunch of related stats generated .......

[2021-01-18 13:41:17,717] C02CD0BNMD6N/INFO/locust.main: Time limit reached. Stopping Locust.
[2021-01-18 13:41:17,717] C02CD0BNMD6N/DEBUG/locust.runners: Stopping all users
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Updating state to 'cleanup', old state was 'running'
[2021-01-18 13:41:17,718] C02CD0BNMD6N/INFO/locust.runners: Stopping 5 users
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Stopping Greenlet-0
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Stopping Greenlet-1
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Stopping Greenlet-2
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Stopping Greenlet-3
[2021-01-18 13:41:17,718] C02CD0BNMD6N/DEBUG/locust.runners: Stopping Greenlet-4

Traceback (most recent call last):
  File "src/gevent/event.py", line 159, in gevent._gevent_cevent.Event.wait
  File "src/gevent/_abstract_linkable.py", line 437, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
  File "src/gevent/_abstract_linkable.py", line 403, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 406, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 358, in gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified
  File "src/gevent/_abstract_linkable.py", line 367, in gevent._gevent_c_abstract_linkable.AbstractLinkable._switch_to_hub
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
greenlet.GreenletExit
Exception ignored in: 'grpc._cython.cygrpc.run_loop'

Steps to reproduce

I am using locust to test bunch of GRPC services and tasks involve bunch of GRPC calls.

Environment

  • OS: MacOS Catalina 10.15.7
  • Python version: 3.8
  • Locust version: 1.4.1, grpcio version : 1.30.0
  • Locust command line that you ran: locust --host myhost -f locustfile --headless -u 5 -r 3 -t 30s MyLocustClass

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
barrachricommented, May 19, 2021

Thanks @beandrad, it does work 👍

1reaction
beandradcommented, May 19, 2021

def on_stop(self, force=False): should be def stop(self, force=False):

Read more comments on GitHub >

github_iconTop Results From Across the Web

GRPC compatibility : Locust load test throws greenlet ...
Describe the bug. Locust load test throws greenlet.GreenletExit exception on reaching test time limit while testing GRPC based services.
Read more >
Testing other systems/protocols — Locust 2.14.0 documentation
Lets assume we have an XML-RPC server that we want to load test. ... from locust.exception import LocustError # patch grpc so that...
Read more >
https://raw.githubusercontent.com/locustio/locust/...
[2.13.0](https://github.com/locustio/locust/tree/2.13.0) (2022-10-28) [Full ... load test throws greenlet.GreenletExit exception on reaching test time limit ...
Read more >
How To Increase Rps In Distributed Locust Load Test - ADocLib
GreenletExit exception on reaching test time limit #1676 Fix test issue ... 2.0 got released #1759; GRPC compatibility : Locust load test throws...
Read more >
How to Load test gRPC Applications with Locust.io in python
This article gives a brief introduction to how you can load test gRPC based applications written in any programming languages like Java or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found