Coder Social home page Coder Social logo

Comments (2)

chunji08 avatar chunji08 commented on June 12, 2024 1

What do you mean "the api call hangs until the time running out"?

In the middle my Locust running, if the response1 failure happened, and I had it "return", then till the end of this locust running, I don't see any extra response1 or response2 calls are made.

Thanks for the tips, I will give a try.

Thanks.

Jack

from locust.

cyberw avatar cyberw commented on June 12, 2024

If I was to have it executed with extra users, in some running session, the first API call hits the failure, and return back 400 code. In my current code, I was doing "return", which hopes the current session to be stopped, and a new one would be started. But I don't see it happens. What I have noticed is, all the API call hangs until the time running out.

What do you mean "the api call hangs until the time running out"?

I recommend running the test in a debugger or adding some print statements.

a) return is fine, should work pretty much the way you expect, unless you mean you want to run on_start again
b) dont throw StopUser, it is an internal thing (we should probably rename it _StopUser or something...)
c) not really. The one thing that I think you may be confused about is the fact that Users loop forever. Their session is never terminated and on_start only happens once. If you need fine grained control use a flag:

class MyUser(HttpUser):
    first_run = True

    @task
    def t(self):
        if self.first_run:
            self.first_run = False
            # Initialization code goes here      
        ...
        # if current call fails, needs to restart from scratch.  
        if response1.status_code != 200:
           self.first_run = True
           return

Another way to do it is just to call on start directly:

    # if current call fails, needs to restart from scratch.  
    if response1.status_code != 200:
       self.on_start()
       return

from locust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.