locust 2.29.1.dev31__py3-none-any.whl → 2.29.2.dev6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- locust/_version.py +2 -2
- locust/clients.py +14 -18
- locust/contrib/fasthttp.py +15 -5
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/METADATA +1 -1
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/RECORD +9 -9
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/WHEEL +1 -1
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/LICENSE +0 -0
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/entry_points.txt +0 -0
- {locust-2.29.1.dev31.dist-info → locust-2.29.2.dev6.dist-info}/top_level.txt +0 -0
locust/_version.py
CHANGED
@@ -12,5 +12,5 @@ __version__: str
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
13
13
|
version_tuple: VERSION_TUPLE
|
14
14
|
|
15
|
-
__version__ = version = '2.29.
|
16
|
-
__version_tuple__ = version_tuple = (2, 29,
|
15
|
+
__version__ = version = '2.29.2.dev6'
|
16
|
+
__version_tuple__ = version_tuple = (2, 29, 2, 'dev6')
|
locust/clients.py
CHANGED
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|
7
7
|
from urllib.parse import urlparse, urlunparse
|
8
8
|
|
9
9
|
import requests
|
10
|
-
from requests import
|
10
|
+
from requests import Response
|
11
11
|
from requests.adapters import HTTPAdapter
|
12
12
|
from requests.auth import HTTPBasicAuth
|
13
13
|
from requests.exceptions import InvalidSchema, InvalidURL, MissingSchema, RequestException
|
@@ -54,8 +54,10 @@ absolute_http_url_regexp = re.compile(r"^https?://", re.I)
|
|
54
54
|
|
55
55
|
|
56
56
|
class LocustResponse(Response):
|
57
|
-
|
58
|
-
|
57
|
+
error: Exception | None = None
|
58
|
+
|
59
|
+
def raise_for_status(self) -> None:
|
60
|
+
if self.error:
|
59
61
|
raise self.error
|
60
62
|
Response.raise_for_status(self)
|
61
63
|
|
@@ -112,7 +114,7 @@ class HttpSession(requests.Session):
|
|
112
114
|
self.mount("https://", LocustHttpAdapter(pool_manager=pool_manager))
|
113
115
|
self.mount("http://", LocustHttpAdapter(pool_manager=pool_manager))
|
114
116
|
|
115
|
-
def _build_url(self, path):
|
117
|
+
def _build_url(self, path) -> str:
|
116
118
|
"""prepend url with hostname unless it's already an absolute URL"""
|
117
119
|
if absolute_http_url_regexp.match(path):
|
118
120
|
return path
|
@@ -191,7 +193,7 @@ class HttpSession(requests.Session):
|
|
191
193
|
response_time = (time.perf_counter() - start_perf_counter) * 1000
|
192
194
|
|
193
195
|
request_before_redirect = (response.history and response.history[0] or response).request
|
194
|
-
url = request_before_redirect.url
|
196
|
+
url = request_before_redirect.url # type: ignore
|
195
197
|
|
196
198
|
if not name:
|
197
199
|
name = request_before_redirect.path_url
|
@@ -225,7 +227,7 @@ class HttpSession(requests.Session):
|
|
225
227
|
pass
|
226
228
|
return response
|
227
229
|
|
228
|
-
def _send_request_safe_mode(self, method, url, **kwargs):
|
230
|
+
def _send_request_safe_mode(self, method, url, **kwargs) -> Response | LocustResponse:
|
229
231
|
"""
|
230
232
|
Send an HTTP request, and catch any exception that might occur due to connection problems.
|
231
233
|
|
@@ -238,8 +240,8 @@ class HttpSession(requests.Session):
|
|
238
240
|
except RequestException as e:
|
239
241
|
r = LocustResponse()
|
240
242
|
r.error = e
|
241
|
-
r.status_code = 0
|
242
|
-
r.request =
|
243
|
+
r.status_code = 0
|
244
|
+
r.request = e.request # type: ignore
|
243
245
|
return r
|
244
246
|
|
245
247
|
def get(
|
@@ -440,17 +442,11 @@ class LocustHttpAdapter(HTTPAdapter):
|
|
440
442
|
|
441
443
|
|
442
444
|
# Monkey patch Response class to give some guidance
|
443
|
-
def
|
444
|
-
raise LocustError(
|
445
|
-
"If you want to change the state of the request, you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
|
446
|
-
)
|
447
|
-
|
448
|
-
|
449
|
-
def _failure(self):
|
445
|
+
def _missing_catch_response_True(self, *_args, **_kwargs):
|
450
446
|
raise LocustError(
|
451
|
-
"If you want to change the state of the request, you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
|
447
|
+
"If you want to change the state of the request using .success() or .failure(), you must pass catch_response=True. See http://docs.locust.io/en/stable/writing-a-locustfile.html#validating-responses"
|
452
448
|
)
|
453
449
|
|
454
450
|
|
455
|
-
Response.success =
|
456
|
-
Response.failure =
|
451
|
+
Response.success = _missing_catch_response_True # type: ignore[attr-defined]
|
452
|
+
Response.failure = _missing_catch_response_True # type: ignore[attr-defined]
|
locust/contrib/fasthttp.py
CHANGED
@@ -157,7 +157,7 @@ class FastHttpSession:
|
|
157
157
|
headers: dict | None = None,
|
158
158
|
auth=None,
|
159
159
|
json: dict | None = None,
|
160
|
-
allow_redirects=True,
|
160
|
+
allow_redirects: bool = True,
|
161
161
|
context: dict = {},
|
162
162
|
**kwargs,
|
163
163
|
) -> ResponseContextManager | FastResponse:
|
@@ -187,6 +187,7 @@ class FastHttpSession:
|
|
187
187
|
and can instead be consumed by accessing the stream attribute on the Response object.
|
188
188
|
Another side effect of setting stream to True is that the time for downloading the response
|
189
189
|
content will not be accounted for in the request time that is reported by Locust.
|
190
|
+
:param allow_redirects: (optional) Set to True by default.
|
190
191
|
"""
|
191
192
|
# prepend url with hostname unless it's already an absolute URL
|
192
193
|
built_url = self._build_url(url)
|
@@ -250,7 +251,7 @@ class FastHttpSession:
|
|
250
251
|
# Record the consumed time
|
251
252
|
# Note: This is intentionally placed after we record the content_size above, since
|
252
253
|
# we'll then trigger fetching of the body (unless stream=True)
|
253
|
-
request_meta["response_time"] =
|
254
|
+
request_meta["response_time"] = (time.perf_counter() - start_perf_counter) * 1000
|
254
255
|
|
255
256
|
if catch_response:
|
256
257
|
return ResponseContextManager(response, environment=self.environment, request_meta=request_meta)
|
@@ -264,6 +265,7 @@ class FastHttpSession:
|
|
264
265
|
return response
|
265
266
|
|
266
267
|
def delete(self, url, **kwargs):
|
268
|
+
"""Sends a DELETE request"""
|
267
269
|
return self.request("DELETE", url, **kwargs)
|
268
270
|
|
269
271
|
def get(self, url, **kwargs):
|
@@ -279,12 +281,12 @@ class FastHttpSession:
|
|
279
281
|
return self.request("OPTIONS", url, **kwargs)
|
280
282
|
|
281
283
|
def patch(self, url, data=None, **kwargs):
|
282
|
-
"""Sends a
|
284
|
+
"""Sends a PATCH request"""
|
283
285
|
return self.request("PATCH", url, data=data, **kwargs)
|
284
286
|
|
285
|
-
def post(self, url, data=None, **kwargs):
|
287
|
+
def post(self, url, data=None, json=None, **kwargs):
|
286
288
|
"""Sends a POST request"""
|
287
|
-
return self.request("POST", url, data=data, **kwargs)
|
289
|
+
return self.request("POST", url, data=data, json=json, **kwargs)
|
288
290
|
|
289
291
|
def put(self, url, data=None, **kwargs):
|
290
292
|
"""Sends a PUT request"""
|
@@ -324,6 +326,12 @@ class FastHttpUser(User):
|
|
324
326
|
Note that setting this value has no effect when custom client_pool was given, and you need to spawn a your own gevent pool
|
325
327
|
to use it (as Users only have one greenlet). See test_fasthttp.py / test_client_pool_concurrency for an example."""
|
326
328
|
|
329
|
+
proxy_host: str | None = None
|
330
|
+
"""Parameter passed to FastHttpSession"""
|
331
|
+
|
332
|
+
proxy_port: int | None = None
|
333
|
+
"""Parameter passed to FastHttpSession"""
|
334
|
+
|
327
335
|
client_pool: HTTPClientPool | None = None
|
328
336
|
"""HTTP client pool to use. If not given, a new pool is created per single user."""
|
329
337
|
|
@@ -355,6 +363,8 @@ class FastHttpUser(User):
|
|
355
363
|
client_pool=self.client_pool,
|
356
364
|
ssl_context_factory=self.ssl_context_factory,
|
357
365
|
headers=self.default_headers,
|
366
|
+
proxy_host=self.proxy_host,
|
367
|
+
proxy_port=self.proxy_port,
|
358
368
|
)
|
359
369
|
"""
|
360
370
|
Instance of HttpSession that is created upon instantiation of User.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
locust/__init__.py,sha256=Hmw2vNf75eLQ1mQIPXAwlQrJ_XFY65MOb92fGsNCukQ,1458
|
2
2
|
locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
|
3
|
-
locust/_version.py,sha256=
|
3
|
+
locust/_version.py,sha256=Fp7LKyDqlYGFAa7QXLGAIjGKtXQ9SKDlrNxaLTEoAB8,426
|
4
4
|
locust/argument_parser.py,sha256=sjQoJ1NTac9LdNYT7zn8RajlWqBQs8YFNv6uRExb2gg,28941
|
5
|
-
locust/clients.py,sha256=
|
5
|
+
locust/clients.py,sha256=OHPv6hBAt4gt3HI67yqyT1qrSsF8uMdCwIRu0kIsRWI,19491
|
6
6
|
locust/debug.py,sha256=We6Z9W0btkKSc7PxWmrZx-xMynvOOsKhG6jmDgQin0g,5134
|
7
7
|
locust/dispatch.py,sha256=vYh0QEDFgJ3hY0HgSk-EiNO7IP9ffzXF_Et8wB9JvsI,16995
|
8
8
|
locust/env.py,sha256=sP-fCnZs0e2xodRemLHgTgyyUt5eezwtdA9WsCoqJkQ,12767
|
@@ -18,7 +18,7 @@ locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
|
|
18
18
|
locust/stats.py,sha256=5jx9aD9Sky-kCZ3E-MjRT3xbwvxo9xyDtfcfP56zclo,45875
|
19
19
|
locust/web.py,sha256=rN1NVeZ9LKSEeDwvpRbOJ0bcy8U1U4VjP-7vK7ejlwM,27367
|
20
20
|
locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
|
-
locust/contrib/fasthttp.py,sha256=
|
21
|
+
locust/contrib/fasthttp.py,sha256=oQPym5pqrX4M7voiHSyzpJ9RasSU7JAkNDhhAj_T30g,27129
|
22
22
|
locust/rpc/__init__.py,sha256=nVGoHWFQxZjnhCDWjbgXIbmFbN9sizAjkhvSs9_642c,58
|
23
23
|
locust/rpc/protocol.py,sha256=n-rb3GZQcAlldYDj4E4GuFGylYj_26GSS5U29meft5Y,1282
|
24
24
|
locust/rpc/zmqrpc.py,sha256=AAY6w7wSFHsW34qqN28666boHFf6dTSAXPQJnAO6iUI,2707
|
@@ -71,9 +71,9 @@ locust/webui/dist/report.html,sha256=sOdZZVgZbqgu86BBCSQf3uQUYXgmgSnXF32JpnyAII8
|
|
71
71
|
locust/webui/dist/assets/favicon.ico,sha256=IUl-rYqfpHdV38e-s0bkmFIeLS-n3Ug0DQxk-h202hI,8348
|
72
72
|
locust/webui/dist/assets/index-84c63e70.js,sha256=cwyH4ju0OCRvFhg3O-0SYVBTFlN_XQeQ6YkymAO4Hco,1647185
|
73
73
|
locust/webui/dist/assets/logo.png,sha256=EIVPqr6wE_yqguHaqFHIsH0ZACLSrvNWyYO7PbyIj4w,19299
|
74
|
-
locust-2.29.
|
75
|
-
locust-2.29.
|
76
|
-
locust-2.29.
|
77
|
-
locust-2.29.
|
78
|
-
locust-2.29.
|
79
|
-
locust-2.29.
|
74
|
+
locust-2.29.2.dev6.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
|
75
|
+
locust-2.29.2.dev6.dist-info/METADATA,sha256=fDif-kfVxmoqn95md2q4OtMPIwOumDQ7QmpvVGaJt4w,7389
|
76
|
+
locust-2.29.2.dev6.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
77
|
+
locust-2.29.2.dev6.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
|
78
|
+
locust-2.29.2.dev6.dist-info/top_level.txt,sha256=XSsjgPA8Ggf9TqKVbkwSqZFuPlZ085X13M9orDycE20,7
|
79
|
+
locust-2.29.2.dev6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|