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.

on_stop method not work, tuple index out of range

See original GitHub issue

I think the problem is the request/response timeout. But it does not show the assertion failed. And it needs to be shut down normally

Describe the bug

  • Set Locust users number: 20
  • Set spawn rate: 10
  • Set run time: 90 secs

Problems:

  • Some users did not call the on_stop method
  • The task method is still called after on_stop called
  • Exhausted my time limit (90 seconds)

Expected behavior

All users call on_stop and shutdown locust.

Actual behavior

I tried to interrupt the process because it never stops and it shows:

[2021-02-05 02:45:09,267] e34866ebd6ad/INFO/locust.main: Running teardowns...
[2021-02-05 02:45:09,267] e34866ebd6ad/INFO/locust.main: Shutting down (exit code 1), bye.
[2021-02-05 02:45:09,267] e34866ebd6ad/INFO/locust.main: Cleaning up runner...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/locust/main.py", line 426, in main
    main_greenlet.join()
  File "/usr/local/lib/python3.8/site-packages/gevent/pool.py", line 430, in join
    result = self._empty_event.wait(timeout=timeout)
  File "src/gevent/event.py", line 163, in gevent._gevent_cevent.Event.wait
  File "src/gevent/_abstract_linkable.py", line 521, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait
  File "src/gevent/_abstract_linkable.py", line 487, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 490, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 442, in gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified
  File "src/gevent/_abstract_linkable.py", line 451, in gevent._gevent_c_abstract_linkable.AbstractLinkable._switch_to_hub
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/locust", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/locust/main.py", line 433, in main
    shutdown()
  File "/usr/local/lib/python3.8/site-packages/locust/main.py", line 408, in shutdown
    runner.quit()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 362, in quit
    self.stop()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 413, in stop
    super().stop()
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 354, in stop
    self.stop_users(self.user_count)
  File "/usr/local/lib/python3.8/site-packages/locust/runners.py", line 223, in stop_users
    user = g.args[0]
IndexError: tuple index out of range

Steps to reproduce

  1. Inherit HttpUser class
  2. on_start -> Login user and setup
  3. on_stop -> Delete user and teardown
  4. task -> do something will be take much time

Environment

  • OS:
  • Docker version: 19.03.14
  • Locust version: 1.4.3
  • Locust command line that you ran: docker run -it --rm -v /home/users/workspace/tests/locust/:/mnt/locust locustio/locust:1.4.3 -f /mnt/locust/load_test.py -u 20-r 10 -t 90 -headless

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
mm25712423commented, Feb 18, 2021

Sorry, my fault. I found an error in my locust file. Fix it and done The command syntax error is because I typed it in the github web application instead of copying and pasting it 😛.

0reactions
github-actions[bot]commented, May 1, 2021

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

IndexError: tuple index out of range ----- Python
It's saying that the index (position) you are accessing doesn't exist. – Ramchandra Apte. Nov 30, 2013 at 3:34. what code ...
Read more >
Python IndexError: tuple index out of range Solution
The IndexError: tuple index out of range error occurs when you try to access an item in a tuple that does not exist....
Read more >
Python Index Error: Tuple Index Out of Range
Ways to fix tuple index out of range error. 1. Check the lower end of the index. 2. Check the upper end of...
Read more >
IndexError: tuple index out of range
In the code above, there is a tuple called tup having three elements. So the index value starts from 0 and ends at...
Read more >
IndexError: Python tuple index out of range
The IndexError: Python tuple index out of range error occurs when you try to access an item in a tuple that does not...
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