Skip to content

Commit

Permalink
Merge pull request #1683 from max-rocket-internet/shape_headless_exit
Browse files Browse the repository at this point in the history
Shutdown workers when using LoadTestShape and headless mode
  • Loading branch information
cyberw authored Jan 20, 2021
2 parents 510466b + 0964040 commit f676961
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def timelimit_stop():
if options.run_time:
logger.info("Run time limit set to %s seconds" % options.run_time)
spawn_run_time_limit_greenlet()
elif options.headless and not options.worker:
elif options.headless and not options.worker and not environment.shape_class:
logger.info("No run time limit set, use CTRL+C to interrupt.")
else:
pass # dont log anything - not having a time limit is normal when not running headless
Expand Down
5 changes: 4 additions & 1 deletion locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ def shape_worker(self):
new_state = self.environment.shape_class.tick()
if new_state is None:
logger.info("Shape test stopping")
self.stop()
if self.environment.parsed_options.headless:
self.quit()
else:
self.stop()
elif self.shape_last_state == new_state:
gevent.sleep(1)
else:
Expand Down
1 change: 1 addition & 0 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def tick(self):
)
self.assertIn("Shape test updating to 10 users at 1.00 spawn rate", output)
self.assertIn("Cleaning up runner...", output)
self.assertIn("Quitting...", output)

def test_web_options(self):
port = get_free_tcp_port()
Expand Down

0 comments on commit f676961

Please sign in to comment.