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

self._sleep() should not be private. #550

Closed
robvdl opened this issue Feb 23, 2017 · 3 comments
Closed

self._sleep() should not be private. #550

robvdl opened this issue Feb 23, 2017 · 3 comments

Comments

@robvdl
Copy link

robvdl commented Feb 23, 2017

It would be much better just to remove the underscore, I am calling it a bit from my tasksets, not sure why it's even private.

@cgoldberg
Copy link
Member

You can get a similar effect using wait(), and setting your TaskSet's min_wait and max_wait set to the same value.

however, see /locust/core.py ... there are some subtle differences between _sleep() and wait(), and I'm not sure using sleep is really what you want.

@heyman
Copy link
Member

heyman commented Feb 23, 2017

Using TaskSet._sleep() is exactly the same as calling gevent.sleep() which is the same as calling time.sleep() (since it's been monkey patched by gevent). Actually I think we could consider removing _sleep() and instead calling gevent.sleep() directly.

@robvdl robvdl closed this as completed Feb 28, 2017
@jessebrennan
Copy link

My particular use case for this was I wanted to sleep while within a task because some endpoints I'm testing give a retry-after header. It seems like just calling self._sleep() (or even gevent.sleep()) accomplishes exactly what I'm looking for.

Maybe this case is atypical, but also I don't see a problem making it a public part of the API.

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

4 participants