Only the first user class is being spawned when running locust as library
See original GitHub issueDescribe the bug
I’m running Locust as a library, when instantiating the environment, only the first user class gets spawn up
Expected behavior
All user classes should be span up with the right amount of stimulated users
Actual behavior
only the first specified used class in the environment is being spawned
Steps to reproduce
please see the code snippet
Environment
- OS: MacOS
- Python version: 3.7
- Locust version: image “1.2.3”
- Locust command line that you ran: running locust as a library in a main method
- Locust file contents (anonymized if necessary):
user class A
class AUsers(HttpUser):
host = os.environ.get("A_HOST")
wait_time = constant_pacing(1)
tasks = [ATask]
User class B
class BUser(HttpUser):
host = os.environ.get("B_HOST")
wait_time = constant_pacing(1)
tasks = [Btasks]
Master main module :
env = Environment(user_classes=[BUser,AUser])
def run_manager(self):
logging.info('*******************')
logging.info('{}'.format("Starting Manager"))
logging.info('*******************')
self.env.step_load = True
self.env.create_master_runner()
self.env.create_web_ui("0.0.0.0", 8089)
gevent.spawn(stats.stats_history, self.env.runner)
self.env.runner.greenlet.join()
if __name__ == "__main__":
manager = ManagerEnv()
manager.run_manager()
Worker main module
env = Environment(user_classes=[BUser,AUser])
def run_worker(self):
logging.info('*******************')
logging.info('{}'.format("Starting Worker"))
logging.info('*******************')
self.env.create_worker_runner(os.environ.get('MANAGER_HOST'), 5557)
gevent.spawn(stats_printer(self.env.stats))
self.env.runner.greenlet.join()
if __name__ == "__main__":
worker = Worker()
worker.run_worker()
logs : /INFO/locust.runners: All users spawned: BUser: 1, AUser: 0 (4 already running)
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Writing a locustfile — Locust 1.2.3 documentation
A user class represents one user (or a swarming locust if you will). Locust will spawn one instance of the User class for...
Read more >Not able to simulate 2 users after every 5 seconds at ...
And I need to change user spawning logic in runner.py and shape.py inside locust library. Reason: Locust does not spawn 2 full users...
Read more >4 Useful Advanced Features in Locust | by Ng Wai Foong
Fortunately, Locust provides a LoadTestShape class which can be used to control the user count and spawn rate based on your needs. All...
Read more >Performance testing using locust with parallel requests - Medium
The above code makes use of gevent library and spawns as many instances of requests needed for a single user and this is...
Read more >Locust - Python based Performance Testing Tool (By Naveen ...
Demonstrating First Load Test using Locust 3. Results Analysis in Locust 4. Data Parameterization in Locust 5. Correlation in Locust 6.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @mboutet, for elaborating. in that case the I can say my original issue is resolved and I can’t wait for it to be merged. nicely done!
@naveen-kinnal, it’s an environment variable for the Manager’s URL.