locust 2.40.2.dev8__py3-none-any.whl → 2.40.2.dev15__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/contrib/socketio.py +52 -48
- {locust-2.40.2.dev8.dist-info → locust-2.40.2.dev15.dist-info}/METADATA +1 -1
- {locust-2.40.2.dev8.dist-info → locust-2.40.2.dev15.dist-info}/RECORD +7 -7
- {locust-2.40.2.dev8.dist-info → locust-2.40.2.dev15.dist-info}/WHEEL +0 -0
- {locust-2.40.2.dev8.dist-info → locust-2.40.2.dev15.dist-info}/entry_points.txt +0 -0
- {locust-2.40.2.dev8.dist-info → locust-2.40.2.dev15.dist-info}/licenses/LICENSE +0 -0
locust/_version.py
CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
28
28
|
commit_id: COMMIT_ID
|
29
29
|
__commit_id__: COMMIT_ID
|
30
30
|
|
31
|
-
__version__ = version = '2.40.2.
|
32
|
-
__version_tuple__ = version_tuple = (2, 40, 2, '
|
31
|
+
__version__ = version = '2.40.2.dev15'
|
32
|
+
__version_tuple__ = version_tuple = (2, 40, 2, 'dev15')
|
33
33
|
|
34
34
|
__commit_id__ = commit_id = None
|
locust/contrib/socketio.py
CHANGED
@@ -1,63 +1,34 @@
|
|
1
1
|
from locust import User
|
2
|
+
from locust.event import EventHook
|
3
|
+
|
4
|
+
from typing import Any
|
2
5
|
|
3
6
|
import gevent
|
4
7
|
import socketio
|
5
8
|
|
6
9
|
|
7
|
-
class
|
8
|
-
|
9
|
-
SocketIOUser wraps an instance of :class:`socketio.Client` to log requests.
|
10
|
-
See example in :gh:`examples/socketio/socketio_ex.py`.
|
11
|
-
"""
|
12
|
-
|
13
|
-
abstract = True
|
14
|
-
options: dict = {}
|
15
|
-
"""socketio.Client options, e.g. `{"reconnection_attempts": 1, "reconnection_delay": 2}`"""
|
16
|
-
client: socketio.Client
|
17
|
-
"""The underlying :class:`socketio.Client` instance. Can be useful to call directly if you want to skip logging a requests."""
|
18
|
-
|
19
|
-
def __init__(self, *args, **kwargs):
|
10
|
+
class SocketIOClient(socketio.Client):
|
11
|
+
def __init__(self, request_event: EventHook, *args, **kwargs):
|
20
12
|
super().__init__(*args, **kwargs)
|
21
|
-
self.
|
22
|
-
self.ws_greenlet = gevent.spawn(self.client.wait)
|
23
|
-
self.client.on("*", self.on_message)
|
24
|
-
|
25
|
-
#
|
26
|
-
def on_message(self, event: str, data: str) -> None:
|
27
|
-
"""
|
28
|
-
This is the default handler for events. You can override it for custom behavior,
|
29
|
-
or even register separate handlers using self.client.on(event, handler)
|
30
|
-
|
31
|
-
Measuring response_time isn't obvious for for WebSockets. Sometimes a response time
|
32
|
-
can be inferred from the event data (if it contains a timestamp) or related to
|
33
|
-
a message that you sent. Override this method in your User class to do that.
|
34
|
-
"""
|
35
|
-
self.environment.events.request.fire(
|
36
|
-
request_type="WSR",
|
37
|
-
name=event,
|
38
|
-
response_time=0,
|
39
|
-
response_length=len(data or []),
|
40
|
-
exception=None,
|
41
|
-
context={},
|
42
|
-
)
|
13
|
+
self.request_event = request_event
|
43
14
|
|
44
15
|
def connect(self, *args, **kwargs):
|
45
16
|
"""
|
46
17
|
Wraps :meth:`socketio.Client.connect`.
|
47
18
|
"""
|
48
|
-
with self.
|
49
|
-
|
19
|
+
with self.request_event.measure("WS", "connect") as _:
|
20
|
+
super().connect(*args, **kwargs)
|
50
21
|
|
51
|
-
def send(self,
|
22
|
+
def send(self, data, namespace=None, callback=None, name="Unnamed") -> None:
|
52
23
|
"""
|
53
24
|
Wraps :meth:`socketio.Client.send`.
|
54
25
|
"""
|
55
26
|
exception = None
|
56
27
|
try:
|
57
|
-
|
28
|
+
super().send(data, namespace, callback)
|
58
29
|
except Exception as e:
|
59
30
|
exception = e
|
60
|
-
self.
|
31
|
+
self.request_event.fire(
|
61
32
|
request_type="WSS",
|
62
33
|
name=name,
|
63
34
|
response_time=0,
|
@@ -66,18 +37,18 @@ class SocketIOUser(User):
|
|
66
37
|
context={},
|
67
38
|
)
|
68
39
|
|
69
|
-
def emit(self,
|
40
|
+
def emit(self, event, data=None, namespace=None, callback=None) -> None:
|
70
41
|
"""
|
71
42
|
Wraps :meth:`socketio.Client.emit`.
|
72
43
|
"""
|
73
44
|
exception = None
|
74
45
|
try:
|
75
|
-
|
46
|
+
super().emit(event, data, namespace, callback)
|
76
47
|
except Exception as e:
|
77
48
|
exception = e
|
78
|
-
self.
|
49
|
+
self.request_event.fire(
|
79
50
|
request_type="WSE",
|
80
|
-
name=
|
51
|
+
name=str(event),
|
81
52
|
response_time=0,
|
82
53
|
response_length=len(data or []),
|
83
54
|
exception=exception,
|
@@ -88,8 +59,41 @@ class SocketIOUser(User):
|
|
88
59
|
"""
|
89
60
|
Wraps :meth:`socketio.Client.call`.
|
90
61
|
"""
|
91
|
-
with self.
|
92
|
-
return
|
62
|
+
with self.request_event.measure("WSC", event) as _:
|
63
|
+
return super().call(event, data, *args, **kwargs)
|
93
64
|
|
94
|
-
def
|
95
|
-
|
65
|
+
def on_message(self, event: str, data: str) -> None:
|
66
|
+
"""
|
67
|
+
This is the default handler for events received.
|
68
|
+
You can register separate handlers using self.sio.on(event, handler)
|
69
|
+
|
70
|
+
Measuring response_time isn't obvious for for WebSockets/SocketIO so we set them to 0.
|
71
|
+
Sometimes response time can be inferred from the event data (if it contains a timestamp)
|
72
|
+
or related to a message that you sent. Override this method in your User class to do that.
|
73
|
+
"""
|
74
|
+
self.request_event.fire(
|
75
|
+
request_type="WSR",
|
76
|
+
name=event,
|
77
|
+
response_time=0,
|
78
|
+
response_length=len(data or []),
|
79
|
+
exception=None,
|
80
|
+
context={},
|
81
|
+
)
|
82
|
+
|
83
|
+
|
84
|
+
class SocketIOUser(User):
|
85
|
+
"""
|
86
|
+
SocketIOUser creates an instance of :class:`socketio.Client` to log requests.
|
87
|
+
See example in :gh:`examples/socketio/socketio_ex.py`.
|
88
|
+
"""
|
89
|
+
|
90
|
+
abstract = True
|
91
|
+
options: dict[str, Any] = {}
|
92
|
+
"""socketio.Client options, e.g. `{"reconnection_attempts": 1, "reconnection_delay": 2, "logger": True, "engineio_logger": True}`"""
|
93
|
+
sio: SocketIOClient
|
94
|
+
|
95
|
+
def __init__(self, *args, **kwargs):
|
96
|
+
super().__init__(*args, **kwargs)
|
97
|
+
self.sio = SocketIOClient(self.environment.events.request, **self.options)
|
98
|
+
self.sio_greenlet = gevent.spawn(self.sio.wait)
|
99
|
+
self.sio.on("*", self.sio.on_message)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
locust/__init__.py,sha256=HadpgGidiyCDPSKwkxrk1Qw6eB7dTmftNJVftuJzAiw,1876
|
2
2
|
locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
|
3
|
-
locust/_version.py,sha256=
|
3
|
+
locust/_version.py,sha256=1lUD_y3GdgwY5ZP5Qi49KZlF9bRAYb_27xyeCkXcsGk,721
|
4
4
|
locust/argument_parser.py,sha256=t6mAoK9u13DxC9UH-alVqS6fFABFTyNWSJG89yQ4QQQ,33056
|
5
5
|
locust/clients.py,sha256=Gj1rD73_G7G7f6bi0plDiN-GIDPTBng8pBY21cFozQc,20219
|
6
6
|
locust/debug.py,sha256=7CCm8bIg44uGH2wqBlo1rXBzV2VzwPicLxLewz8r5CQ,5099
|
@@ -23,7 +23,7 @@ locust/contrib/milvus.py,sha256=YabgLd0lImzWupJFCm0OZAW-Nxeibwn91ldWpZ2irDo,1281
|
|
23
23
|
locust/contrib/mongodb.py,sha256=1seUYgJOaNKwybYOP9PUEVhgl8hGy-G33f8lFj3R8W8,1246
|
24
24
|
locust/contrib/oai.py,sha256=Ot3T8lp31ThckGbNps86oVvq6Vn845Eec0mxhDmONDE,2684
|
25
25
|
locust/contrib/postgres.py,sha256=OuMWnGYN10K65Tq2axVESEW25Y0g5gJb0rK90jkcCJg,1230
|
26
|
-
locust/contrib/socketio.py,sha256=
|
26
|
+
locust/contrib/socketio.py,sha256=iznaDtXx7ytd60-_oJAb6tc9T26tJ-NcL6vLeTh-AtQ,3236
|
27
27
|
locust/rpc/__init__.py,sha256=5YOu-58XSnt-oWWNATgXLTNdYoDkkngwHNXprxkWKSM,99
|
28
28
|
locust/rpc/protocol.py,sha256=n-rb3GZQcAlldYDj4E4GuFGylYj_26GSS5U29meft5Y,1282
|
29
29
|
locust/rpc/zmqrpc.py,sha256=tMeLQiLII8QP29lAHGZsj5Pf5FsTL-X4wM0DrtR3ALw,3214
|
@@ -56,8 +56,8 @@ locust/webui/dist/assets/terminal.gif,sha256=iw80LO2u0dnf4wpGfFJZauBeKTcSpw9iUfI
|
|
56
56
|
locust/webui/dist/assets/testruns-dark.png,sha256=G4p2VZSBuuqF4neqUaPSshIp5OKQJ_Bvb69Luj6XuVs,125231
|
57
57
|
locust/webui/dist/assets/testruns-light.png,sha256=JinGDiiBPOkhpfF-XCbmQqhRInqItrjrBTLKt5MlqVI,130301
|
58
58
|
pytest_locust/plugin.py,sha256=WAyiRHLynXegbbX2DxIutPKO4PQRT6JdBFA7zbbaJgM,1469
|
59
|
-
locust-2.40.2.
|
60
|
-
locust-2.40.2.
|
61
|
-
locust-2.40.2.
|
62
|
-
locust-2.40.2.
|
63
|
-
locust-2.40.2.
|
59
|
+
locust-2.40.2.dev15.dist-info/METADATA,sha256=Twi0mcXhfvVh7tKWHwHemQTdyVoDofdcAHnIYFD8JE0,9599
|
60
|
+
locust-2.40.2.dev15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
61
|
+
locust-2.40.2.dev15.dist-info/entry_points.txt,sha256=0uIHcQ71R1qaWhM_sd8uBUCCJgp7gJfGHUVMnJeZfcY,86
|
62
|
+
locust-2.40.2.dev15.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
|
63
|
+
locust-2.40.2.dev15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|