@task decorator
What Is the @task Decorator?
@task Decorator?Example: Printing DateTime and a Greeting
from locust import User, task, between
from datetime import datetime
class MyUser(User):
# Defines the wait time between tasks to be a random value between 1 and 5 seconds.
wait_time = between(1, 5)
@task
def print_datetime(self):
# This task prints the current date and time.
print(datetime.now())
@task
def print_greeting(self):
# This task prints a greeting message.
print("Hello!")
Explanation of the Code
Fine-Tuning Tasks with Weights
Last updated