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

aborting task in on_start #435

Closed
xrmx opened this issue Jun 21, 2016 · 5 comments
Closed

aborting task in on_start #435

xrmx opened this issue Jun 21, 2016 · 5 comments

Comments

@xrmx
Copy link

xrmx commented Jun 21, 2016

I call a function that may fail in TaskSet.on_start

    def on_start(self):
        self.token = self.get_token(user)

I've added a self.interrupt(reschedule=False) call if the function fail but the docstring of the that method says i should not do that from the root taskset.

And in fact i got these errors logged:

[2016-06-21 17:16:29,939] rieux/ERROR/stderr: raise InterruptTaskSet(reschedule)
[2016-06-21 17:16:29,939] rieux/ERROR/stderr: LocustError: A task inside a Locust class' main TaskSet (`WebsiteUser.task_set` of type `UserBehavior`) seems to have called interrupt() or raised an InterruptTaskSet exception. The interrupt() function is used to hand over execution to a parent TaskSet, and should never be called in the main TaskSet which a Locust class' task_set attribute points to.
[2016-06-21 17:16:29,939] rieux/ERROR/stderr: <Greenlet at 0x7f2c67b432d0: start_locust(<class 'http.WebsiteUser'>)> failed with LocustError

How can i avoid to run a task i know would return an error?

@heyman
Copy link
Member

heyman commented Oct 7, 2016

What is it that you want to happen when it fails in on_start?

@xrmx
Copy link
Author

xrmx commented Oct 7, 2016

My memory is a bit foggy on the topic, anyway i think consider the creation of the locust instance as failed but continue with the hatch of the others.

@heyman
Copy link
Member

heyman commented Oct 7, 2016

I see. That's not something that is currently supported and unless there's a strong use-case for it, I don't think it's something that will be implemented in Locust.

However, I guess the result in your case was that the failed locust instances stopped, but the ones that didn't failed continued to execute. Which might be sort of equivalent of having some kind of failed state (even though the logs were filled with stacktraces)?

@heyman heyman closed this as completed Oct 7, 2016
@danihodovic
Copy link

Ping in 2024. My use case is that I want the Locust user to abort if authentication fails because all subsequent calls by that user will fail due to auth errors.

@akabeera
Copy link

I have the same use case

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

No branches or pull requests

4 participants