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.
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
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: