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

Error when executing Environment.runner.start_shape #1981

Closed
linhngocle2000 opened this issue Jan 24, 2022 · 2 comments
Closed

Error when executing Environment.runner.start_shape #1981

linhngocle2000 opened this issue Jan 24, 2022 · 2 comments
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it

Comments

@linhngocle2000
Copy link

linhngocle2000 commented Jan 24, 2022

Describe the bug

I'm using locust as library and experimenting with custom load shape.

Expected behavior

Load increasing by 10 users every 30 seconds.

Actual behavior

The following error is shown when I run the code:

  File "\path_to_locustfile", line 44, in <module>
    env.runner.start_shape()
  File "\path_to_file\locust\runners.py", line 384, in start_shape
    self.environment.shape_class.reset_time()
TypeError: reset_time() missing 1 required positional argument: 'self'
  File "\path_to_file\locust\runners.py", line 389, in shape_worker
    new_state = self.environment.shape_class.tick()
TypeError: tick() missing 1 required positional argument: 'self'

Steps to reproduce

This is my code:

import gevent
import math
from locust import HttpUser, task, between, constant
from locust.env import Environment
from locust.stats import stats_printer, stats_history
from locust.log import setup_logging
from locust.shape import LoadTestShape

setup_logging("INFO", None)


class StepLoadShape(LoadTestShape):

    step_time = 30
    step_load = 10
    spawn_rate = 10
    time_limit = 600

    def tick(self):
        run_time = self.get_run_time()

        if run_time > self.time_limit:
            return None

        current_step = math.floor(run_time / self.step_time) + 1
        return (current_step * self.step_load, self.spawn_rate)


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

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


env = Environment(user_classes=[User], shape_class=StepLoadShape, host="https://docs.locust.io/")
env.create_local_runner()
gevent.spawn(stats_printer(env.stats))
gevent.spawn(stats_history, env.runner)
env.runner.start_shape()
gevent.spawn_later(600, lambda: env.runner.quit())
env.runner.greenlet.join()

Environment

  • OS: Windows 10 Pro
  • Python version: Python 3.9
  • Locust version: 2.6.0
  • Locust command line that you ran: python /path_to_file
  • Locust file contents (anonymized if necessary):
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it label Mar 26, 2022
@github-actions
Copy link

github-actions bot commented Apr 5, 2022

This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!

@github-actions github-actions bot closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it
Projects
None yet
Development

No branches or pull requests

1 participant