Vladimir
Vladimir

Reputation: 497

How to run Locust task n times

Want to run nested Locust task n iterations in every sequential task set. The only way that I've found for Locust 1.x versions is to multiply task in tasks:

class TaskA(SequentialTaskSet):
    ...
class TaskB(SequentialTaskSet):
     n = 5
     tasks = [TaskA for _ in range(n)]

What is the better and more correct way to run TaskA n times? Options 1 & 2 below don't work in 1.3.1:

1:

class TaskB(SequentialTaskSet):    
    for _ in range(n):
        tasks = [TaskA]

2:

class TaskB(TaskSet):    
    for _ in range(n):
        tasks = {TaskA: n}

Upvotes: 0

Views: 1510

Answers (1)

Cyberwiz
Cyberwiz

Reputation: 11426

Usually the answer to

How do I do X with a SequentialTaskSet?

is

Don't use a SequentialTaskSet, just use Python!

Can you achieve the same thing with a regular for loop & functions?

tasks = [TaskA for _ in range(n)] seems ok though, unless it doesnt do what you want it to?

Upvotes: 1

Related Questions