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

Users making more request than expected. #2630

Closed
2 tasks done
rafaeltovargarrido opened this issue Mar 13, 2024 · 1 comment
Closed
2 tasks done

Users making more request than expected. #2630

rafaeltovargarrido opened this issue Mar 13, 2024 · 1 comment

Comments

@rafaeltovargarrido
Copy link

Prerequisites

Description

I have one FastHttpUser with one SequentialTaskSet with 3 tasks (one, two and tres) I want those tasks run only one-time peer user,
meaning if I run the locust script I will expect to have 10 calls for tasks one,two and tres.

The issue is I can see more requests for those tasks, in the image you can see for example for task one I have 42 requests, maybe the control of running only one time is no correct.

Also, my idea is to kill the user after the 3 task are completely done.

Thanks for the help.

l2

locust

Command line

locust -f t.py --processes 1

Locustfile contents

from locust import User, TaskSet, constant
from locust.exception import RescheduleTask,RescheduleTaskImmediately
from locust import FastHttpUser, task, events,SequentialTaskSet, HttpUser, constant, task
import logging
import gevent
from locust.exception import RescheduleTask,StopUser,RescheduleTaskImmediately
global locust_count
class ForumSection(SequentialTaskSet):

    def on_start(self):
        self.one = None
        self.two = None
        self.tres = None

    @task
    def one(self):

        if self.one == None:
            print("one")
            self.client.get('https://httpbin.org/',name='one',)
            self.one = True
            
                
    @task
    def two(self):
        if self.two == None:
            print("two")
            self.client.get('https://httpbin.org/status/200',name='two',)
            self.two = True

    @task
    def tres(self):

        if self.tres == None:
            print("tre")
            self.client.get('https://httpbin.org/status/200',name='tres',)
            self.tres = True
            self.user.stop(True)

class LoggedInUser(FastHttpUser):
    token = None

    tasks = [ForumSection]
    def on_stop(self):
        print("stssttt")
LoggedInUser.host = "https://auth-oat-unit01.dev.gcp-eu.taocloud.org"        


#

Python version

Python 3.11.7

Locust version

locust 2.24.0

Operating system

manjoro

@cyberw
Copy link
Collaborator

cyberw commented Mar 14, 2024

Hi! Github issues is reserrved for issues/bugs, please ask questions on stackoverflow or on slack. This behaviour is as designed, because by default users run as fast as they can.

To limit the number of task runs you could try using locust-plugins's iteration limiter https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/cmd_line_examples.sh#L10 but it might not be an exact fit for your scenario.

@cyberw cyberw closed this as completed Mar 14, 2024
@cyberw cyberw added the invalid label Mar 14, 2024
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