locust 2.38.2.dev7__py3-none-any.whl → 2.38.2.dev21__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 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.38.2.dev7'
32
- __version_tuple__ = version_tuple = (2, 38, 2, 'dev7')
31
+ __version__ = version = '2.38.2.dev21'
32
+ __version_tuple__ = version_tuple = (2, 38, 2, 'dev21')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -0,0 +1,5 @@
1
+ # This directory contains modules that are experimental.
2
+
3
+ # Generally they should not have any significant issues, but they may change without a major version bump for locust.
4
+
5
+ # Some modules may require optional dependencies, typically installed with `pip install locust[name-of-module]`.
@@ -0,0 +1,95 @@
1
+ from locust import User
2
+
3
+ import gevent
4
+ import socketio
5
+
6
+
7
+ class SocketIOUser(User):
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):
20
+ super().__init__(*args, **kwargs)
21
+ self.client = socketio.Client(**self.options)
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
+ )
43
+
44
+ def connect(self, *args, **kwargs):
45
+ """
46
+ Wraps :meth:`socketio.Client.connect`.
47
+ """
48
+ with self.environment.events.request.measure("WS", "connect") as _:
49
+ self.client.connect(*args, **kwargs)
50
+
51
+ def send(self, name, data=None, namespace=None) -> None:
52
+ """
53
+ Wraps :meth:`socketio.Client.send`.
54
+ """
55
+ exception = None
56
+ try:
57
+ self.client.send(data, namespace)
58
+ except Exception as e:
59
+ exception = e
60
+ self.environment.events.request.fire(
61
+ request_type="WSS",
62
+ name=name,
63
+ response_time=0,
64
+ response_length=len(data or []),
65
+ exception=exception,
66
+ context={},
67
+ )
68
+
69
+ def emit(self, name, data=None, namespace=None, callback=None) -> None:
70
+ """
71
+ Wraps :meth:`socketio.Client.emit`.
72
+ """
73
+ exception = None
74
+ try:
75
+ self.client.emit(name, data, namespace, callback)
76
+ except Exception as e:
77
+ exception = e
78
+ self.environment.events.request.fire(
79
+ request_type="WSE",
80
+ name=name,
81
+ response_time=0,
82
+ response_length=len(data or []),
83
+ exception=exception,
84
+ context={},
85
+ )
86
+
87
+ def call(self, event, data=None, *args, **kwargs):
88
+ """
89
+ Wraps :meth:`socketio.Client.call`.
90
+ """
91
+ with self.environment.events.request.measure("WSC", event) as _:
92
+ return self.client.call(event, data, *args, **kwargs)
93
+
94
+ def on_stop(self):
95
+ self.client.disconnect()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: locust
3
- Version: 2.38.2.dev7
3
+ Version: 2.38.2.dev21
4
4
  Summary: Developer-friendly load testing framework
5
5
  Project-URL: homepage, https://locust.io/
6
6
  Project-URL: repository, https://github.com/locustio/locust
@@ -33,6 +33,7 @@ Requires-Dist: geventhttpclient>=2.3.1
33
33
  Requires-Dist: locust-cloud>=1.26.3
34
34
  Requires-Dist: msgpack>=1.0.0
35
35
  Requires-Dist: psutil>=5.9.1
36
+ Requires-Dist: python-socketio[client]==5.13.0
36
37
  Requires-Dist: pywin32; sys_platform == 'win32'
37
38
  Requires-Dist: pyzmq>=25.0.0
38
39
  Requires-Dist: requests>=2.26.0; python_version <= '3.11'
@@ -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=s2j9gE6VWFZ3Bbw6sbjPzaEsKdu7tciZebcEag4lP4c,719
3
+ locust/_version.py,sha256=p8zeYDV-RC8SI8ouqHrCtIHFcanHPr6XX8PXeHk5P4I,721
4
4
  locust/argument_parser.py,sha256=t6mAoK9u13DxC9UH-alVqS6fFABFTyNWSJG89yQ4QQQ,33056
5
5
  locust/clients.py,sha256=o-277lWQdpmPnoRTdf3IQVNPQT8LMFDtPtuxbLHQIIs,19286
6
6
  locust/debug.py,sha256=7CCm8bIg44uGH2wqBlo1rXBzV2VzwPicLxLewz8r5CQ,5099
@@ -17,12 +17,13 @@ locust/runners.py,sha256=niYmGsfOpxMfVmTXGod4MYTefpaZ2wirFlhqxRw5mq4,70617
17
17
  locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
18
18
  locust/stats.py,sha256=qyoSKT0i7RunLDj5pMGqizK1Sp8bcqUsXwh2m4_DpR8,47203
19
19
  locust/web.py,sha256=HLFN9jUtKG3sMIKu_Xw9wtvTAFxXvzDHdtLtfb_JxUQ,31849
20
- locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ locust/contrib/__init__.py,sha256=LtZN7MczpIAbZkN7PT2h8W2wgb9nBl6cDXbFCVsV4fo,290
21
21
  locust/contrib/fasthttp.py,sha256=QfVpcdo5oKOO1rKLXeCeTJ4t57XU1lhIIWeUeeSJtIE,29650
22
22
  locust/contrib/milvus.py,sha256=YabgLd0lImzWupJFCm0OZAW-Nxeibwn91ldWpZ2irDo,12811
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=PpXKHFTlQgFNNkdwU3N3AvJ18XERoQtxxTmOira0Lyo,3152
26
27
  locust/rpc/__init__.py,sha256=5YOu-58XSnt-oWWNATgXLTNdYoDkkngwHNXprxkWKSM,99
27
28
  locust/rpc/protocol.py,sha256=n-rb3GZQcAlldYDj4E4GuFGylYj_26GSS5U29meft5Y,1282
28
29
  locust/rpc/zmqrpc.py,sha256=tMeLQiLII8QP29lAHGZsj5Pf5FsTL-X4wM0DrtR3ALw,3214
@@ -54,8 +55,8 @@ locust/webui/dist/assets/index-BjqxSg7R.js,sha256=3JyrKWfAg8LlTy2bxAJh73c6njNPhN
54
55
  locust/webui/dist/assets/terminal.gif,sha256=iw80LO2u0dnf4wpGfFJZauBeKTcSpw9iUfISXT2nEF4,75302
55
56
  locust/webui/dist/assets/testruns-dark.png,sha256=G4p2VZSBuuqF4neqUaPSshIp5OKQJ_Bvb69Luj6XuVs,125231
56
57
  locust/webui/dist/assets/testruns-light.png,sha256=JinGDiiBPOkhpfF-XCbmQqhRInqItrjrBTLKt5MlqVI,130301
57
- locust-2.38.2.dev7.dist-info/METADATA,sha256=Y85K_sULv2Nnz46NJgs-rAr3QeH01cT0OOlBsy9LyoA,9476
58
- locust-2.38.2.dev7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
59
- locust-2.38.2.dev7.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
60
- locust-2.38.2.dev7.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
61
- locust-2.38.2.dev7.dist-info/RECORD,,
58
+ locust-2.38.2.dev21.dist-info/METADATA,sha256=XpyoRPuFbgJt-ljIUQtbZpIDS_0nq5VALqWQVIbWshU,9524
59
+ locust-2.38.2.dev21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
+ locust-2.38.2.dev21.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
61
+ locust-2.38.2.dev21.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
62
+ locust-2.38.2.dev21.dist-info/RECORD,,