Skip to content

Commit

Permalink
Merge pull request #2224 from locustio/fix-exception-when-someone-set…
Browse files Browse the repository at this point in the history
…s-both-headless-and-autostart

Fix exception when someone sets both --headless and --autostart
  • Loading branch information
cyberw authored Oct 14, 2022
2 parents 83c07d0 + fe87da8 commit dff5d08
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,14 @@ def main():
logger.error("Credentials supplied with --web-auth should have the format: username:password")
sys.exit(1)
else:
if options.autostart:
logger.warning("Option --autostart is ignored for headless mode and worker process.")
web_ui = None

if options.autostart and options.headless:
logger.warning("The --autostart argument is implied by --headless, no need to set both.")

if options.autostart and options.worker:
logger.warning("The --autostart argument has no meaning on a worker.")

def assign_equal_weights(environment, **kwargs):
environment.assign_equal_weights()

Expand All @@ -291,7 +295,7 @@ def assign_equal_weights(environment, **kwargs):
main_greenlet = web_ui.greenlet

def stop_and_optionally_quit():
if options.autostart:
if options.autostart and not options.headless:
logger.info("--run-time limit reached, stopping test")
runner.stop()
if options.autoquit != -1:
Expand Down Expand Up @@ -450,7 +454,7 @@ def save_html_report():
logger.info(f"Starting Locust {version}")
if options.class_picker:
logger.info("Locust is running with the UserClass Picker Enabled")
if options.autostart:
if options.autostart and not options.headless:
start_automatic_run()

main_greenlet.join()
Expand Down

0 comments on commit dff5d08

Please sign in to comment.