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

Restore locust_start_hatching functionality #1776

Closed
nathan-beam opened this issue Jun 3, 2021 · 2 comments · Fixed by #1777
Closed

Restore locust_start_hatching functionality #1776

nathan-beam opened this issue Jun 3, 2021 · 2 comments · Fixed by #1777

Comments

@nathan-beam
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Previous versions of Locust included an event called locust_start_hatching. This event was similar to test_start, except that it was fired on all threads, not just on the master thread, when distributed. There was even a separate master_start_hatching that functioned identically to test_start does currently, so the removal of the locust_start_hatching event seems to be a pure loss of functionality, which one of my projects relied on. It is useful for my worker threads to instantiate certain data at the time of test initialization, which is currently only possible through some very unfortunate hacks.

Describe the solution you'd like

The addition of an event that fires when any thread starts a test

Describe alternatives you've considered

My current hack is to check if the required data has been initialized in all of my user constructors, and initialize it there if not. This is obviously not a good solution.

Additional context

The event was removed in commit 220f9cea, seemingly because its purpose was unclear and it was missing tests. Hopefully this feature request can clarify its purpose, but if not I'd be happy to expound upon it further.

@cyberw
Copy link
Collaborator

cyberw commented Jun 4, 2021

I agree, that does sound like a loss of functionality. Tbh, I think the appropriate solution is making test_start fire on all nodes (you could then check the environment.runner type to see if you are on master or slave, as needed). I think that was probably the way it was intended - I just documented it the way @heyman implemented it.

Any chance you could contribute such a fix? (and update the docs accordingly, maybe with an example that shows how to check master/slave) I dont think I have time for this...

@nathan-beam
Copy link
Contributor Author

I will see if I can put up a pull request soon.

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

Successfully merging a pull request may close this issue.

2 participants