Skip to content
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

"Order of events" clarification #1349

Closed
ecc256 opened this issue Apr 22, 2020 · 4 comments
Closed

"Order of events" clarification #1349

ecc256 opened this issue Apr 22, 2020 · 4 comments

Comments

@ecc256
Copy link

ecc256 commented Apr 22, 2020

Guys,
Question / clarification about Locust setup (once)
Indeed, it’s called once only, for very 1st HttpLocust instance.

I've set an instance attribute in setup(self) is instance method.
Consequently, only 1st HttpLocust instance has the attribute set.
All others HttpLocust instances won’t have the attribute and throw an exception on access.

Naturally, setting class attribute instead will take care of it.

A thought:
Since Locust setup() is called once only, should it be class method, not instance one?
Would be nice to add Locust on_start (once per locust) instance method too, seems a bit more logical to me...

Above applies to TaskSet too:
TaskSet setup (once) - should be class method, not instance
TaskSet on_start (once per locust) - is instance method

Not complaining or anything, just want to throw an idea!
Thanks

@cyberw
Copy link
Collaborator

cyberw commented Apr 22, 2020

Hi! You are totally right! It is very confusing! It is fixed in the upcoming (as in any day now) 1.0 release though :)

If you want to try it out right away, try installing locust from latest master (pip3 install -e git://github.com/locustio/locust.git@master#egg=locustio) and check out the documentation here https://docs.locust.io/en/latest/writing-a-locustfile.html#setups-teardowns-on-start-and-on-stop

@cyberw cyberw closed this as completed Apr 22, 2020
@ecc256
Copy link
Author

ecc256 commented Apr 22, 2020

Would love to test!!
Ugh... I don't see "setups-teardowns-on-start-and-on-stop" section in the link you posted...
There is on-start-and-on-stop-methods only:
https://docs.locust.io/en/latest/writing-a-locustfile.html#on-start-and-on-stop-methods

@cyberw
Copy link
Collaborator

cyberw commented Apr 22, 2020

Yea, setup/teardown has been replaced by test_start/stop. Guess my link was from my browser history, sorry :)

@ecc256
Copy link
Author

ecc256 commented Apr 22, 2020

Tested latest branch - works great!
Thanks a lot for your work!
And for switching to newer gevent too!
gevent 1.5.0 pypi_0 pypi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants