zoukankan      html  css  js  c++  java
  • locust库的运行总报错?

    脚本:

    from locust import HttpLocust,TaskSet,task

    class MyBlogs(TaskSet):
    # 访问我的博客首页
    @task(1)
    def get_blog(self):
    # 定义请求头
    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"}

    req = self.client.get("/imyalost", headers=header, verify=False)
    if req.status_code == 200:
    print("success")
    else:
    print("fails")

    class websitUser(HttpLocust):
    task_set = MyBlogs
    min_wait = 3000 # 单位为毫秒
    max_wait = 6000 # 单位为毫秒

    if __name__ == "__main__":
    import os
    os.system("locust -f demo1.py --host=https://www.cnblogs.com")

    报错信息:

    [2020-07-14 09:41:32,911] yinqianjun/INFO/locust.main: Starting web monitor at http://*:8089
    [2020-07-14 09:41:32,911] yinqianjun/ERROR/stderr: Traceback (most recent call last):
    [2020-07-14 09:41:32,911] yinqianjun/ERROR/stderr: File "D:pythonlib unpy.py", line 193, in _run_module_as_main
    [2020-07-14 09:41:32,911] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr: "__main__", mod_spec)
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr: File "D:pythonlib unpy.py", line 85, in _run_code
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr: exec(code, run_globals)
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr: File "C:Users52573PycharmProjectszuoyevenvScriptslocust.exe\__main__.py", line 9, in <module>
    [2020-07-14 09:41:32,912] yinqianjun/ERROR/stderr: File "c:users52573pycharmprojectszuoyevenvlibsite-packageslocustmain.py", line 559, in main
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr: gevent.signal(signal.SIGTERM, sig_term_handler)
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr:
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr: TypeError
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr: :
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr: 'module' object is not callable
    [2020-07-14 09:41:32,913] yinqianjun/ERROR/stderr:

    解决方法:刚学网上照猫画虎,尚未解决·······

    每天进步一点点!
  • 相关阅读:
    集合总结
    dagger2系列之Scope
    dagger2系列之依赖方式dependencies、包含方式(从属方式)SubComponent
    dagger2系列之生成类实例
    Dagger2系列之使用方法
    Handler系列之内存泄漏
    Handler系列之创建子线程Handler
    Handler系列之原理分析
    Handler系列之使用
    HTML标签
  • 原文地址:https://www.cnblogs.com/qianjunjun/p/13297443.html
Copyright © 2011-2022 走看看