-4

from locust import Locust, TaskSet

def login(l): print("I am logged In")

def logout(m): print("I am logged Out")

class UserBehaviour(TaskSet):

task=[login,logout]

class User(Locust): task_set = UserBehaviour

Error Message---

(venv) C:\pythnprojects\LearnLocustProject\venv\locust_test>locust -f firstlocust.py

[2020-03-11 00:38:57,259] DELLXPS/INFO/locust.main: Starting web monitor at *:8089

[2020-03-11 00:38:57,259] DELLXPS/INFO/locust.main: Starting Locust 0.11.0

[2020-03-11 00:39:05,581] DELLXPS/INFO/locust.runners: Hatching and swarming 1 clients at the rate 1 clients/s...

[2020-03-11 00:39:05,585] DELLXPS/ERROR/stderr: Traceback (most recent call last):

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run

self.schedule_task(self.get_next_task())

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task

return random.choice(self.tasks)

File "C:\DOWNLOADS\lib\random.py", line 290, in choice

raise IndexError('Cannot choose from an empty sequence') from None

IndexError: Cannot choose from an empty sequence

[2020-03-11 00:39:06,582] DELLXPS/INFO/locust.runners: All locusts hatched: User: 1

[2020-03-11 00:39:06,591] DELLXPS/ERROR/stderr: Traceback (most recent call last):

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run

self.schedule_task(self.get_next_task())

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task

return random.choice(self.tasks)

File "C:\DOWNLOADS\lib\random.py", line 290, in choice

raise IndexError('Cannot choose from an empty sequence') from None

IndexError: Cannot choose from an empty sequence

[2020-03-11 00:39:07,597] DELLXPS/ERROR/stderr: Traceback (most recent call last):

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 358, in run

self.schedule_task(self.get_next_task())

File "c:\pythnprojects\learnlocustproject\venv\lib\site-packages\locust\core.py", line 419, in get_next_task

return random.choice(self.tasks)

File "C:\DOWNLOADS\lib\random.py", line 290, in choice

raise IndexError('Cannot choose from an empty sequence') from None

IndexError: Cannot choose from an empty sequence

Sam
  • 1
  • 2

1 Answers1

1

It looks like you've misspelled tasks (it currently seems to say task).

heyman
  • 4,845
  • 3
  • 26
  • 19
  • Thanks. In addition to it, in Locust 14.0, wait_time = between(5.0, 9.0) is mandatory, which was I believe was not the case in earlier versions. – Sam Mar 12 '20 at 14:06