Skip to content

tag doesn't work fine #2849

Closed
Closed
@evanchaoli

Description

@evanchaoli

Prerequisites

Description

With this simple locusfile:

from locust import HttpUser, task, tag


class RevisionApiUser(HttpUser):
    @tag('revision')
    @task
    def get_commit_list(self):
        print("revision")


class CBotApiUser(HttpUser):
    @tag('cbot')
    @task
    def get_commits(self):
        print("cbot")

Then run locust with a tag specified:

$ locust --tags cbot
[2024-08-14 15:05:43,870] C02GM2X6MD6R/ERROR/locust.user.task: No tasks defined on RevisionApiUser. Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)
Traceback (most recent call last):
  File "/Users/chaol/venv/3.9/lib/python3.9/site-packages/locust/user/task.py", line 335, in run
    self.schedule_task(self.get_next_task())
  File "/Users/chaol/venv/3.9/lib/python3.9/site-packages/locust/user/task.py", line 479, in get_next_task
    raise Exception(
Exception: No tasks defined on RevisionApiUser. Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)

From the UI, the test looks run properly, only CBotApiUser is executed. However, the terminal keeps scrolling the error message.

Command line

locust --tags cbot

Locustfile contents

from locust import HttpUser, task, tag


class RevisionApiUser(HttpUser):
    @tag('revision')
    @task
    def get_commit_list(self):
        print("revision")


class CBotApiUser(HttpUser):
    @tag('cbot')
    @task
    def get_commits(self):
        print("cbot")

Python version

3.9.19

Locust version

locust 2.31.2 from /Users/chaol/venv/3.9/lib/python3.9/site-packages/locust (Python 3.9.19, OpenSSL 3.3.0)

Operating system

MacOS

Metadata

Metadata

Assignees

Labels

bughacktoberfestSee https://hacktoberfest.digitalocean.com for more infostaleIssue had no activity. Might still be worth fixing, but dont expect someone else to fix it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions