locustio / locust

Write scalable load tests in plain Python 🚗💨
MIT License
24.64k stars 2.96k forks source link

No users count send in hatch_complete #678

Closed zeburek closed 6 years ago

zeburek commented 6 years ago

Description of issue / feature request

No users count information sent in events.hatch_complete

Expected behavior

Adding new handler with 1 parameters will receive users_count information

Actual behavior

[2017-11-09 14:16:35,676] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 536, in run
[2017-11-09 14:16:35,698] inp1wst013/ERROR/stderr: result = self._run(*self.args, **self.kwargs)
[2017-11-09 14:16:35,698] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/locust/runners.py", line 205, in <lambda>
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: self.hatching_greenlet = gevent.spawn(lambda: super(LocalLocustRunner, self).start_hatching(locust_count, hatch_rate, wait=wait))
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/locust/runners.py", line 175, in start_hatching
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: self.spawn_locusts(locust_count, wait=wait)
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/locust/runners.py", line 125, in spawn_locusts
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: hatch()
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/locust/runners.py", line 110, in hatch
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: events.hatch_complete.fire(user_count=self.num_clients)
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: File "/usr/local/lib/python2.7/dist-packages/locust/events.py", line 27, in fire
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: handler(**kwargs)
[2017-11-09 14:16:35,707] inp1wst013/ERROR/stderr: TypeError: set_users() takes exactly 1 argument (0 given)
[2017-11-09 14:16:35,708] inp1wst013/ERROR/stderr: Thu Nov  9 14:16:35 2017

Environment settings (for bug reports)

Steps to reproduce (for bug reports)

import time
from locust import events

users_count = []

def set_users(users, **kw):
    users_count.append({
        "timestamp": time.time(),
        "users": users
    })

events.hatch_complete += set_users

Add this code to locustfile and try to run locust

akantak commented 6 years ago

in set_users function the argument should have name user_count instead of users, as it is called by locust always as key value parameter.