Closed ThomasSteinbach closed 4 years ago
I havent validated the behaviour you are seeing, but it definitely looks like a bug, or at least a feature we would want.
This is not supposed to happen within the same Locust I think. If it does happen I'd really like to see a minimal reproducible example.
It's definitely possible that on_stop
could be run on Locust User B while the on_start
is still executing in Locust User A. That is something that we can'tdo much about since it would requiring synchronization across distributed nodes.
Sorry, I realised what I wrote in the previous message is incorrect. For some reason I thought you meant that on_stop could run before on_start, but I can clearly see that's not what you wrote.
It's correct that with the current implementation we do not wait for on_start to finish when the test is stopped. Instead the Locusts' greenlets are immediately killed which could happen while on_start is still being executed if it's long running, or the test is stopped very quickly after it has been started. I think #1099 might be able to change this behaviour though.
Yes, this is pretty much solved by #1099 . I added a test case to verify it, and will PR it later (it turns out on_start and on_stop are not tested anywhere...)
Description of issue / feature request
Wait with running
on_stop
untilon_start
has finished. This is becauseon_stop
could depend on variables / statuses set duringon_start
:[Edit]
Same case for tasks. The
on_stop
method would maybe not cleanup resources from the currently running task: