Created
May 3, 2013 13:37
-
-
Save nmccready/5509151 to your computer and use it in GitHub Desktop.
locust via lamda?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import Locust, TaskSet | |
urls = ["someurl1", "someurl2"] | |
lamda_set = {} | |
for url in urls: | |
lamda_set[lambda l: l.client.get(url)] = 1 | |
class UserBehavior(TaskSet): | |
tasks = lamda_set | |
def on_start(self): | |
pass | |
class WebsiteUser(Locust): | |
task_set = UserBehavior | |
min_wait = 1000 | |
max_wait = 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GOT it!!! With help from here, http://stackoverflow.com/questions/452610/how-do-i-create-a-list-of-python-lambdas-in-a-list-comprehension-for-loop
Basically the lambda was being stored to the same reference. So by defining a function to return a lambda, it creates a new one each time.