opnsense-ports/benchmarks/py-locust/files/extra-EXAMPLES-semaphore_wait.py
Franco Fichtner 38f38f6cef */*: sync with upstream
Taken from: HardenedBSD
2019-01-20 14:45:08 +01:00

25 lines
568 B
Python

from locust import HttpLocust, TaskSet, task, events
from gevent.coros import Semaphore
all_locusts_spawned = Semaphore()
all_locusts_spawned.acquire()
def on_hatch_complete(**kw):
all_locusts_spawned.release()
events.hatch_complete += on_hatch_complete
class UserTasks(TaskSet):
def on_start(self):
all_locusts_spawned.wait()
self.wait()
@task
def index(self):
self.client.get("/")
class WebsiteUser(HttpLocust):
host = "http://127.0.0.1:8089"
min_wait = 2000
max_wait = 5000
task_set = UserTasks