Skip to content

Commit

Permalink
make sure locusts are spawned in local run otherwise it will exit une…
Browse files Browse the repository at this point in the history
…xpectedly
  • Loading branch information
delulu committed Dec 6, 2019
1 parent 7eec53d commit 2e148ba
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ def timelimit_stop():
runners.locust_runner.start_stepload(options.num_clients, options.hatch_rate, options.step_clients, options.step_time)
elif not options.slave:
runners.locust_runner.start_hatching(options.num_clients, options.hatch_rate)
# make locusts are spawned
time.sleep(1)
elif not options.slave:
# spawn web greenlet
logger.info("Starting web monitor at http://%s:%s" % (options.web_host or "*", options.port))
Expand Down

3 comments on commit 2e148ba

@heyman
Copy link
Member

@heyman heyman commented on 2e148ba Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delulu Do you remember the reason for this sleep() call? I can't seem to make it break without it.

@delulu
Copy link
Contributor Author

@delulu delulu commented on 2e148ba Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delulu Do you remember the reason for this sleep() call? I can't seem to make it break without it.

there's a typo in comment, it should be "make sure locusts are spawned".

In local run and non-web mode, the main_greenlet is pointing to runners.locust_runner.greenlet.

If the locusts are not yet spawned, in the execution of code lines below main_greenlet.join() will complete, then shutdown(code=code)
will be called.

locust/locust/main.py

Lines 571 to 575 in 2e148ba

main_greenlet.join()
code = 0
if len(runners.locust_runner.errors) or len(runners.locust_runner.exceptions):
code = options.exit_code_on_error
shutdown(code=code)

@heyman
Copy link
Member

@heyman heyman commented on 2e148ba Mar 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks!

Please sign in to comment.