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

TypeError: 'str' object is not callable #450

Closed
derjust opened this issue Jul 19, 2016 · 1 comment
Closed

TypeError: 'str' object is not callable #450

derjust opened this issue Jul 19, 2016 · 1 comment

Comments

@derjust
Copy link

derjust commented Jul 19, 2016

I followed the quick start guide and failed quite in the beginning:

This is my locustfile.py

from locust import HttpLocust, TaskSet

def status(l):
    l.client.get("/status")

class UserBehavior(TaskSet):
    tasks = {"index":2, "profile":1}

    def on_start(self):
        status(self)

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000

and after starting via

locust --host http://localhost:8080

and selecting any kind of # of user & starting the test, STDOUT gets flooded with

[2016-07-19 09:50:53,764] SGCSNYMACSJUST.local/ERROR/stderr: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 267, in run
    self.execute_next_task()
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 293, in execute_next_task
    self.execute_task(task["callable"], *task["args"], **task["kwargs"])
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 305, in execute_task
    task(self, *args, **kwargs)
TypeError: 'str' object is not callable
@mpanowicz
Copy link

From documentation:

The tasks attribute is either a list of python callables, or a dict.

You declared it as that's why you have this error.

You can declare the UserBehavior just like that:

class UserBehavior(TaskSet):
    tasks = {status}

@heyman heyman closed this as completed Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants