question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

run locust 1.0.1 directly from .py file

See original GitHub issue

Anyway I run locust 1.0.1 directly from .py file? test.py

class MainTaskSet(TaskSet):
	@task
	...

class WebsiteUser(FastHttpUser):
	tasks = [MainTaskSet]

if __name__ == '__main__':
	from locust.main import main
	main()

It used to work, but with 1.0.1 I got: ./test.py Could not find any locustfile! Ensure file ends in ‘.py’ and see --help for available options.

One way is to set env. var with current file name in if __name__ == '__main__' block. Another is to run it as library.

Is there is an easier way to do it? It’s somewhat related to run/debug from locustfile from vscode also…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
ecc256commented, May 20, 2020

I have it already. Just missing the old way I used to run it, that’s all. BTW: It was a suggestion only, don’t take it personal, please! 😃

0reactions
cyberwcommented, May 20, 2020

I have it already. Just missing the old way I used to run it, that’s all. BTW: It was a suggestion only, don’t take it personal, please! 😃

I wasn’t taking it personally, sorry if I made it sound like I did 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick start — Locust 1.0.1 documentation
The locustfile.py is a normal Python file that will get imported by Locust. Within it you can import modules just as you would...
Read more >
Quick start — Locust 1.0.2 documentation
To run Locust distributed across multiple Python processes or machines, you can start a single Locust master process with the --master command line...
Read more >
Installation — Locust 1.0.1 documentation
Once Locust is installed, a locust command should be available in your shell. (if you're not using virtualenv—which you should—make sure your python...
Read more >
Getting started — Locust 2.14.0 documentation
To run Locust distributed across multiple Python processes or machines, you start a single Locust master process with the --master command line parameter,...
Read more >
Running Locust without the web UI — Locust 1.1 documentation
locust -f locust_files/my_locust_file.py --headless -u 1000 -r 100 ... By default, locust will stop your tasks immediately. If you want to allow your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found