-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add worker_count = 1 to LocalRunner for parity with MasterRunner #2900
Add worker_count = 1 to LocalRunner for parity with MasterRunner #2900
Conversation
Hmm... I understand the need in this example, but if I ask a LocalRunner how many workers/clients it has connected I'd expect it to be zero, not one, so this might add as much confusion as it solves... |
I can see that perspective. The way I view it though, when running locally, there is one worker: The runner itself. Nothing happens without a worker right? In fact, it does even have a worker: Line 441 in 7c85b79
The real goal here is to simplify load testing code that I'm writing. Currently, my option is try:
worker_count = environment.runner.worker_count
workers = environment.runner.clients
except AttributeError: # For running locally
worker_count = 1
workers = [environment.runner] Which feels like a hacky workaround for a bug. |
This is also just making for a more complete picture, in light of this comment, directly above the change: Lines 436 to 437 in 7c85b79
|
Hmm... Yea I guess the I dont think there's a clean way to handle this, probably best if you just check the type of the runner object and do special treatment of LocalRunner as necessary. |
🤦🏻 Yes, So, that special code is exactly what I'm trying to avoid. I ran into this because I was refactoring code that had special handling for All that said, this much debate over 2 small lines with no real impact on the code makes it seem not worth it. 🤷🏻 |
I get why this would make it easier for this particular use case, but I don't want LocalRunner to "lie" about its state. LocalRunner has no workers (so saying it has one is questionable) and settings self.workers to be a list containing itself could have very strange consequences down the line, if it were ever used by someone not aware of this feature. Its not even the same type ( |
@cyberw I've updated to remove |
This prevents the
custom_messages
example from failing when running locally withAttributeError
s forenvironment.runner.worker_count
andenvironment.runner.clients
.ref:
locust/examples/custom_messages.py
Lines 45 to 48 in 7c85b79