Locust: Parallel tasks?

Created on 17 Sep 2014  路  1Comment  路  Source: locustio/locust

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.

Most helpful comment

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

>All comments

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanyco92 picture sanyco92  路  4Comments

meeech picture meeech  路  4Comments

radiantone picture radiantone  路  3Comments

dolohow picture dolohow  路  3Comments

wosc picture wosc  路  3Comments