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

TaskSet missing _cp_last_run attribute #2532

Closed
2 tasks done
ionutab opened this issue Jan 4, 2024 · 0 comments · Fixed by #2533
Closed
2 tasks done

TaskSet missing _cp_last_run attribute #2532

ionutab opened this issue Jan 4, 2024 · 0 comments · Fixed by #2533
Labels

Comments

@ionutab
Copy link
Contributor

ionutab commented Jan 4, 2024

Prerequisites

Description

When using the constant_pacing wait time strategy in a task set, an error is thrown.
TaskSet instances do not have a _cp_last_run attribute.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\task.py", line 343, in run
    self.execute_next_task()
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\task.py", line 376, in execute_next_task
    self.execute_task(self._task_queue.pop(0))
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\task.py", line 494, in execute_task
    task(self.user).run()
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\task.py", line 371, in run
    self.wait()
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\task.py", line 449, in wait
    self._sleep(self.wait_time())
                ^^^^^^^^^^^^^^^^
  File "C:\Users\P3701275\projects\20240104_TaskSetTest\venv\Lib\site-packages\locust\user\wait_time.py", line 52, in wait_time_func
    run_time = time() - self._cp_last_run - self._cp_last_wait_time
                        ^^^^^^^^^^^^^^^^^
AttributeError: 'MyTaskSet' object has no attribute '_cp_last_run'

Command line

locust -f locustfile_cp_nested.py -t 20s -H "http://www.google.com" --headless

Locustfile contents

from locust import TaskSet, constant, task, HttpUser, constant_pacing


class MyUser(HttpUser):
    wait_time = constant(1)

    @task
    class MyTaskSet(TaskSet):
        wait_time = constant_pacing(1)

        @task
        def do_something(self):
            self.client.get("/")

Python version

3.11

Locust version

2.20.1

Operating system

Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant