I am looking for a way, where for the below code next user comes in action only if current user is done with all of the tasks mentioned in a sequence. That is user should not be switched unless all tasks in sequence is completed for one user:
from locust import HttpUser,task,SequentialTaskSet,wait_time
@task
def One(self):
print("One")
self.client.get(url="https://www.google.com")
@task
def Two(self):
print("Two")
self.client.get(url="https://www.google.com")
@task
def Three(self):
print("Three")
self.client.get(url="https://www.google.com")
@task
def Four(self):
print("Four")
self.client.get(url="https://www.google.com")
class mysequence(SequentialTaskSet):
@task
def myseq(self):
One(self)
Two(self)
Three(self)
Four(self)
class abc(HttpUser):
wait_time(0,1)
tasks=[mysequence]
As of with this code, user is getting spawned before previous user is done with all its tasks mentioned in the sequence. Please refer below trace:
PS C:\Users\abhijeet.goswami\src> locust -f tests/serial.py -u 5 -r 1 --host
https://prudent-plus-staging.prudentbrokers.in/ --run-time 10s --headless --only-summary
[2025-02-19 13:30:29,786] PGNPF3TAKACLT/INFO/locust.main: Starting Locust 2.32.5
[2025-02-19 13:30:29,786] PGNPF3TAKACLT/INFO/locust.main: Run time limit set to 10 seconds
[2025-02-19 13:30:29,786] PGNPF3TAKACLT/INFO/locust.runners: Ramping to 5 users at a rate of 1.00 per second
One
Two
One
Three
Two
One
Four
Three
Two
One
Four
[2025-02-19 13:30:33,835] PGNPF3TAKACLT/INFO/locust.runners: All users spawned: {"abc": 5} (5 total users)
One
Two
Three