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.

Exceptions raised in setup method causes Locust to break

See original GitHub issue

In locustio 0.13.5, there is a very odd bug that prevents the setup method from using requests to make HTTP requests. When doing an HTTP POST request, the setup function unexpectedly returns. No exception is printed, but the remainder of the function does not execute. This is what my code looks like (edited down for confidentiality):

class MyLocust(HttpLocust):
    def setup(self):
        print('Creating test data')
    
        response = requests.post('https://my-service.company.com', json=test_data)
        assert response.status_code == 201
    
        print('Created test data')  

I added a try/catch to my code and apparently the requests.post() call throws a GreenletExit exception. After much consternation I was able to narrow the issue down to gevent. It appears that the gevent._ssl3 module’s call to self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout) on line 332 throws this GreenletExit error.

Important note: this error does not manifest in locustio 0.12.2 or lower.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
monitorjblcommented, Jan 22, 2020

Yeah, preferably you could use the setup() function the same in both the Locust and the TaskSet. But if there are technical limitations that prevent this, having two functions that operate subtly differently is not a very good experience.

1reaction
monitorjblcommented, Jan 21, 2020

@cyberw I tried moving the setup() into the TaskSet and it appears to work! I still think you should do something about setup() in the Locust throwing this error though. The fact that it appears to support normal setup() functions is misleading and, if the TaskSet is the preferred place to set it, perhaps it would be better to deprecate that particular function.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fail setup in Locust? - python - Stack Overflow
To do that, I'm raising an exception, but locust continues with the tests until time limit is reached. I'd like for it to...
Read more >
Writing a locustfile — Locust 0.13.1 documentation
A locustfile is a normal python file. The only requirement is that it declares at least one class— let's call it the locust...
Read more >
Locust - Read the Docs
Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites (or other systems).
Read more >
A Global Review on Locusts (Orthoptera: Acrididae) and Their ...
We draw attention to “telecoupling” a process in which land management practices like grazing have ecological feedbacks on locust populations, ...
Read more >
Preventing desert locust plagues: optimizing management ...
Outbreaks occur when concentration and multiplication cause a marked increase in locust numbers and densities so that individuals gregarize ...
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