Skip to content

Commit

Permalink
Manually kill stats_printer greenlet to avoid getting double request …
Browse files Browse the repository at this point in the history
…stats output in the console after the “Shutting down” message has been outputted.
  • Loading branch information
heyman committed Nov 15, 2019
1 parent fcb040c commit bf91ce8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,10 @@ def timelimit_stop():
logger.error("Failed to connect to the Locust master: %s", e)
sys.exit(-1)

stats_printer_greenlet = None
if not options.only_summary and (options.print_stats or (options.no_web and not options.slave)):
# spawn stats printing greenlet
gevent.spawn(stats_printer)
stats_printer_greenlet = gevent.spawn(stats_printer)

if options.csvfilebase:
gevent.spawn(stats_writer, options.csvfilebase)
Expand All @@ -505,7 +506,8 @@ def shutdown(code=0):
Shut down locust by firing quitting event, printing/writing stats and exiting
"""
logger.info("Shutting down (exit code %s), bye." % code)

if stats_printer_greenlet is not None:
stats_printer_greenlet.kill(block=False)
logger.info("Cleaning up runner...")
if runners.locust_runner is not None:
runners.locust_runner.quit()
Expand Down

0 comments on commit bf91ce8

Please sign in to comment.