首页_大虾个人博客

locust 增加集合点

  • 作者:大虾
  • 时间:2019年3月12日 07:37
简介类似于Jmter中的集合点的概念
from locust import events  
from gevent._semaphore import Semaphore  
all_locusts_spawned = Semaphore()  
all_locusts_spawned.acquire()  

def on_hatch_complete(**kwargs):  
    all_locusts_spawned.release()  

events.hatch_complete += on_hatch_complete  

class TestTask(TaskSet):  
    def on_start(self):  
        """ on_start is called when a Locust start before any task is scheduled """  
        self.login()  
        all_locusts_spawned.wait()  

 

下一篇:返回列表

Top