Skip to content

Commit

Permalink
Call the User instance method stop()
Browse files Browse the repository at this point in the history
This allows to use an overridden `stop()` method when the Locust
runner stops the user, which allows for more flexibility without
introducing additional complexity.

One of the use cases is being able to close a gRPC channel before
killing the user greenlet.
  • Loading branch information
MIC3LHN committed May 4, 2021
1 parent fe16b85 commit 7c2b283
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def stop_users(self, user_count, stop_rate=None):
# User called runner.quit(), so dont block waiting for killing to finish"
user_to_stop._group.killone(user_to_stop._greenlet, block=False)
elif self.environment.stop_timeout:
async_calls_to_stop.add(gevent.spawn_later(0, User.stop, user_to_stop, force=False))
async_calls_to_stop.add(gevent.spawn_later(0, user_to_stop.stop, force=False))
stop_group.add(user_to_stop._greenlet)
else:
async_calls_to_stop.add(gevent.spawn_later(0, User.stop, user_to_stop, force=True))
async_calls_to_stop.add(gevent.spawn_later(0, user_to_stop.stop, force=True))
if to_stop:
gevent.sleep(sleep_time)
else:
Expand Down

0 comments on commit 7c2b283

Please sign in to comment.