我试图运行一个非常基本的蝗虫负载测试,以前没有工作。
from locust import HttpUser, between, task
class QuickstartUser(HttpUser):
wait_time = between(1, 5)
@task
def get_status(self):
self.client.get("/status/")
运行以下命令:尝试访问Web界面时,locust -f <package-name>/tests/load_tests.py -r 20 -u 400 -H http://localhost:8000
生成以下错误消息:
[2022-12-28 23:23:30,962] MacBook-Pro.fritz.box/INFO/locust.main: Starting web interface at http://0.0.0.0:8089 (accepting connections from all network interfaces)
[2022-12-28 23:23:30,968] MacBook-Pro.fritz.box/INFO/locust.main: Starting Locust 2.14.0
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
File "/Users/<user>/Coding/PycharmProjects/<project>-fastapi/.venv/lib/python3.10/site-packages/gevent/baseserver.py", line 34, in _handle_and_close_when_done
return handle(*args_tuple)
File "/Users/<user>/Coding/PycharmProjects/<project>-fastapi/.venv/lib/python3.10/site-packages/gevent/pywsgi.py", line 1577, in handle
handler.handle()
File "/Users/<user>/Coding/PycharmProjects/<project>-fastapi/.venv/lib/python3.10/site-packages/gevent/pywsgi.py", line 464, in handle
result = self.handle_one_request()
File "/Users/<user>/Coding/PycharmProjects/<project>-fastapi/.venv/lib/python3.10/site-packages/gevent/pywsgi.py", line 656, in handle_one_request
if self.rfile.CLOSED:
AttributeError: '_io.BufferedReader' object has no attribute 'CLOSED'
2022-12-28T22:23:35Z <Greenlet at 0x106fbc3a0: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed] at 0x106fcb460 o)> failed with AttributeError
正在使用以下版本:
$ poetry show locust --tree
locust 2.14.0 Developer friendly load testing framework
├── configargparse >=1.0
├── flask >=2.0.0
│ ├── click >=8.0
│ │ └── colorama *
│ ├── itsdangerous >=2.0
│ ├── jinja2 >=3.0
│ │ └── markupsafe >=2.0
│ └── werkzeug >=2.2.2
│ └── markupsafe >=2.1.1 (circular dependency aborted here)
├── flask-basicauth >=0.2.0
│ └── flask *
│ ├── click >=8.0
│ │ └── colorama *
│ ├── itsdangerous >=2.0
│ ├── jinja2 >=3.0
│ │ └── markupsafe >=2.0
│ └── werkzeug >=2.2.2
│ └── markupsafe >=2.1.1 (circular dependency aborted here)
├── flask-cors >=3.0.10
│ ├── flask >=0.9
│ │ ├── click >=8.0
│ │ │ └── colorama *
│ │ ├── itsdangerous >=2.0
│ │ ├── jinja2 >=3.0
│ │ │ └── markupsafe >=2.0
│ │ └── werkzeug >=2.2.2
│ │ └── markupsafe >=2.1.1 (circular dependency aborted here)
│ └── six *
├── gevent >=20.12.1
│ ├── cffi >=1.12.2
│ │ └── pycparser *
│ ├── greenlet >=2.0.0
│ ├── setuptools *
│ ├── zope-event *
│ │ └── setuptools * (circular dependency aborted here)
│ └── zope-interface *
│ └── setuptools * (circular dependency aborted here)
├── geventhttpclient >=2.0.2
│ ├── brotli *
│ ├── certifi *
│ ├── gevent >=0.13
│ │ ├── cffi >=1.12.2
│ │ │ └── pycparser *
│ │ ├── greenlet >=2.0.0
│ │ ├── setuptools *
│ │ ├── zope-event *
│ │ │ └── setuptools * (circular dependency aborted here)
│ │ └── zope-interface *
│ │ └── setuptools * (circular dependency aborted here)
│ └── six *
├── msgpack >=0.6.2
├── psutil >=5.6.7
├── pywin32 *
├── pyzmq >=22.2.1,<23.0.0 || >23.0.0
│ ├── cffi *
│ │ └── pycparser *
│ └── py *
├── requests >=2.23.0
│ ├── certifi >=2017.4.17
│ ├── charset-normalizer >=2,<3
│ ├── idna >=2.5,<4
│ └── urllib3 >=1.21.1,<1.27
├── roundrobin >=0.0.2
├── typing-extensions >=3.7.4.3
└── werkzeug >=2.0.0
└── markupsafe >=2.1.1
1条答案
按热度按时间pgky5nke1#
我不太清楚为什么,但是我在同一个环境中遇到了一些其他的问题(比如pip更新失败),于是我决定删除整个虚拟环境,然后使用锁文件从头开始创建它,之后,完全相同的代码工作得非常好。