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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步