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

Parallel tasks? #198

Closed
jeffandersen opened this issue Sep 17, 2014 · 1 comment
Closed

Parallel tasks? #198

jeffandersen opened this issue Sep 17, 2014 · 1 comment

Comments

@jeffandersen
Copy link

Is it possible to have tasks run in parallel?

I have a scenario where I want to test users accessing the same resource at potentially the same time (to mimic our real-world behavior) which can potentially result in failures.

@heyman
Copy link
Member

heyman commented Sep 17, 2014

Yep, Locust uses gevent and greenlets, and though each Locust instance runs in it's own greenlet, you could spawn greenlets from within a task yourself. Something like this should work:

@task
def my_task(self):
    from gevent.pool import Group
    group = Group()
    group.spawn(lambda: self.client.get("/some_url")
    group.spawn(lambda: self.client.get("/some_url")
    group.join() # wait for greenlets to finish

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

2 participants