question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IndexError: Cannot choose from an empty sequence

See original GitHub issue

Description of issue / feature request

  File "/media/jawahar/jon1/new_project/bm/testDev/lib/python3.6/site-packages/locust/core.py", line 268, in run
    self.schedule_task(self.get_next_task())
  File "/media/jawahar/jon1/new_project/bm/testDev/lib/python3.6/site-packages/locust/core.py", line 329, in get_next_task
    return random.choice(self.tasks)
  File "/media/jawahar/jon1/new_project/bm/testDev/lib/python3.6/random.py", line 258, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence

Repeately i am getting this error after Start swarming number of users.

Expected behavior

No Error related to this.

Actual behavior

Traceback showed about

Environment settings (for bug reports)

  • OS:Ubuntu 17
  • Python version: 3.6.5
  • Locust version: 0.8.0/0.8.1

Steps to reproduce (for bug reports)

Run some api and you will get this error

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cgoldbergcommented, May 27, 2018

if you write an invalid locustfile and don’t declare tasks, expect things to break. As I said previously, the error message could be improved.

2reactions
cgoldbergcommented, May 26, 2018

IndexError: Cannot choose from an empty sequence

@jawahar273, That exception gets raised when there are no tasks defined. Can you verify you actually declared some tasks in your locustfile? (either use the @tasks decorator or define a class that inherits from TaskSet)

for Locust devs, A nice enhancement would be to catch the IndexError in /locust/core.py and raise a RuntimeError instead… It should display an intuitive message like “No tasks defined in locustfile”, and then exit.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IndexError: Cannot choose from an empty sequence
I am trying to run this command python run.py --mode MLE and got this error. I am not able to find the correct...
Read more >
IndexError: Cannot choose from an empty sequence
I am getting the following error while loading data into the dataloader. why the data loader is unable to load all images and...
Read more >
Python error IndexError Cannot choose from an empty sequence
Your file name seems to be random. Random is a module and can not be used as a file name. Change the filename...
Read more >
IndexError: Cannot choose from an empty sequenceraise ...
IndexError: Cannot choose from an empty sequenceraise IndexError (' Cannot choose from an empty sequence ') from None , solved in Python.
Read more >
Probability Calculator - IndexError: Cannot choose from an ...
This test uses a hat with 19 balls and tries to draw 20. Your code in your draw method does move everything from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found