zoukankan      html  css  js  c++  java
  • python-celery、locust

    一、celery任务队列  
    https://www.jianshu.com/p/620052aadbff
    二、locust
    
    
    from locust import HttpLocust,TaskSet,task,core
    from gevent import monkey
    monkey.patch_all()
    import urllib3
    #禁用安全请求警告
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    
    class  BestTest(TaskSet):
    
        header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"}
    
        #@task装饰该方法表示为用户行为,括号里面参数表示该行为的执行权重:数值越大,执行频率越高,不设置默认是1;
        @task(1)
        def index(self):
            req = self.client.get("/index/home", headers=self.header, verify=False)
            if req.status_code == 200:
                print("success")
            else:
                print("fail")
    
        @task(2)
        def login(self):
            req = self.client.post("/ebox-sso/login",headers=self.header,data={'username': '15669910105', 'password': '*****'})
            if req.status_code == 200:
                print("success")
            else:
                print("fail")
    
    class BestTestIndexUser(HttpLocust):
        task_set = BestTest  #指向定义了用户行为的类
        min_wait = 3000  # 单位为毫秒,负载最小等待时间
        max_wait = 6000  # 单位为毫秒,负载最大等待时间
    
    if __name__ == "__main__":
        import os
        os.system("locust -f locust1.py --host=https://www.e-box.org.cn")   #locust的默认端口号是8090,本地localhost:8089
    
    
    
     
  • 相关阅读:
    C# 检测dll的新版本号方法
    DataGridView 单击赋值
    一致性Hash算法
    .net Parallel并行使用注意事项
    析构函数和Dispose方法的区别
    查看SQLServer的最大连接数
    Hash算法-CityHash算法
    Hash算法
    Sunday算法--C#版
    KMP算法--C#版
  • 原文地址:https://www.cnblogs.com/shuzf/p/12171326.html
Copyright © 2011-2022 走看看