locust 2.20.1.dev11__py3-none-any.whl → 2.20.1.dev22__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
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.20.1.dev11'
16
- __version_tuple__ = version_tuple = (2, 20, 1, 'dev11')
15
+ __version__ = version = '2.20.1.dev22'
16
+ __version_tuple__ = version_tuple = (2, 20, 1, 'dev22')
locust/debug.py CHANGED
@@ -2,6 +2,7 @@ from datetime import datetime, timezone
2
2
  import os
3
3
  import inspect
4
4
  import locust
5
+ import locust.log
5
6
  from locust import User, argument_parser
6
7
  from typing import Type, Optional
7
8
  from locust.env import Environment
@@ -102,7 +103,7 @@ def run_single_user(
102
103
  include_time=False,
103
104
  include_context=False,
104
105
  include_payload=False,
105
- loglevel=None,
106
+ loglevel: Optional[str] = "WARNING",
106
107
  ):
107
108
  """
108
109
  Runs a single User. Useful when you want to run a debugger.
@@ -113,8 +114,8 @@ def run_single_user(
113
114
 
114
115
  It prints some info about every request to stdout, and you can get additional info using the `include_*` flags
115
116
 
116
- By default, it does not set up locusts logging system (because it could interfere with the printing of requests),
117
- but you can change that by passing a log level (e.g. *loglevel="INFO"*)
117
+ It also initiates logging on WARNING level (not INFO, because it could interfere with the printing of requests),
118
+ but you can change that by passing a log level (or disabling logging entirely by passing None)
118
119
  """
119
120
  global _env
120
121
 
@@ -141,6 +142,9 @@ def run_single_user(
141
142
  )
142
143
  # fire various events (quit and test_stop will never get called, sorry about that)
143
144
  _env.events.init.fire(environment=_env, runner=None, web_ui=None)
145
+ # uncaught events will be suppressed, so check if that happened
146
+ if locust.log.unhandled_greenlet_exception:
147
+ raise Exception("Unhandled exception in init")
144
148
 
145
149
  # do the things that the Runner usually does
146
150
  _env.user_classes = [user_class]
locust/event.py CHANGED
@@ -55,7 +55,12 @@ class EventHook:
55
55
  ) -> Generator[Dict[str, Any], None, None]:
56
56
  """Convenience method for firing the event with automatically calculated response time and automatically marking the request as failed if an exception is raised (this is really only useful for the *request* event)
57
57
 
58
- Other attributes in the event can be added/updated inside your with block if you use the "with ... as request_meta:" syntax.
58
+ Example usage (in a task):
59
+
60
+ with self.environment.events.request.measure("myrequestType", "myRequestName") as request_meta:
61
+ # do the stuff you want to measure
62
+
63
+ You can optionally add/overwrite entries in the request_meta dict and they will be passed to the request event.
59
64
 
60
65
  Experimental.
61
66
  """
@@ -91,7 +96,7 @@ class DeprecatedEventHook(EventHook):
91
96
  class Events:
92
97
  request: EventHook
93
98
  """
94
- Fired when a request in completed, successful or unsuccessful. This event is typically used to report requests when writing custom clients for locust.
99
+ Fired when a request in completed.
95
100
 
96
101
  Event arguments:
97
102
 
@@ -102,6 +107,8 @@ class Events:
102
107
  :param response: Response object (e.g. a :py:class:`requests.Response`)
103
108
  :param context: :ref:`User/request context <request_context>`
104
109
  :param exception: Exception instance that was thrown. None if request was successful.
110
+
111
+ If you want to simplify a custom client, you can have Locust measure the time for you by using :meth:`measure() <locust.event.EventHook.measure>`
105
112
  """
106
113
 
107
114
  user_error: EventHook
locust/rpc/zmqrpc.py CHANGED
@@ -13,6 +13,7 @@ class BaseSocket:
13
13
 
14
14
  self.socket.setsockopt(zmq.TCP_KEEPALIVE, 1)
15
15
  self.socket.setsockopt(zmq.TCP_KEEPALIVE_IDLE, 30)
16
+ self.socket.setsockopt(zmq.IPV6, 1)
16
17
 
17
18
  @retry()
18
19
  def send(self, msg):
@@ -23,7 +23,7 @@ class TestDebugging(DebugTestCase):
23
23
 
24
24
  class MyUser1(HttpUser):
25
25
  @task
26
- def my_task():
26
+ def my_task(self):
27
27
  pass
28
28
 
29
29
  def _stop_user():
@@ -34,4 +34,7 @@ class TestDebugging(DebugTestCase):
34
34
  t = Timer(1, _stop_user)
35
35
  t.start()
36
36
 
37
- debug.run_single_user(MyUser1)
37
+ debug.run_single_user(
38
+ MyUser1,
39
+ loglevel=None, # another log setup might mess with other tests...
40
+ )
@@ -8,7 +8,7 @@ from locust.exception import RPCError, RPCSendError, RPCReceiveError
8
8
  class ZMQRPC_tests(LocustTestCase):
9
9
  def setUp(self):
10
10
  super().setUp()
11
- self.server = zmqrpc.Server("127.0.0.1", 0)
11
+ self.server = zmqrpc.Server("*", 0)
12
12
  self.client = zmqrpc.Client("localhost", self.server.port, "identity")
13
13
 
14
14
  def tearDown(self):
@@ -19,8 +19,10 @@ class ZMQRPC_tests(LocustTestCase):
19
19
  def test_constructor(self):
20
20
  self.assertEqual(self.server.socket.getsockopt(zmq.TCP_KEEPALIVE), 1)
21
21
  self.assertEqual(self.server.socket.getsockopt(zmq.TCP_KEEPALIVE_IDLE), 30)
22
+ self.assertEqual(self.server.socket.getsockopt(zmq.IPV6), 1)
22
23
  self.assertEqual(self.client.socket.getsockopt(zmq.TCP_KEEPALIVE), 1)
23
24
  self.assertEqual(self.client.socket.getsockopt(zmq.TCP_KEEPALIVE_IDLE), 30)
25
+ self.assertEqual(self.client.socket.getsockopt(zmq.IPV6), 1)
24
26
 
25
27
  def test_client_send(self):
26
28
  self.client.send(Message("test", "message", "identity"))
@@ -40,15 +42,15 @@ class ZMQRPC_tests(LocustTestCase):
40
42
  self.assertEqual(msg.node_id, "identity")
41
43
 
42
44
  def test_client_retry(self):
43
- server = zmqrpc.Server("127.0.0.1", 0)
45
+ server = zmqrpc.Server("*", 0)
44
46
  server.socket.close()
45
47
  with self.assertRaises(RPCError):
46
48
  server.recv_from_client()
47
49
 
48
50
  def test_rpc_error(self):
49
- server = zmqrpc.Server("127.0.0.1", 0)
51
+ server = zmqrpc.Server("*", 0)
50
52
  with self.assertRaises(RPCError):
51
- server = zmqrpc.Server("127.0.0.1", server.port)
53
+ server = zmqrpc.Server("*", server.port)
52
54
  server.close()
53
55
  with self.assertRaises(RPCSendError):
54
56
  server.send_to_client(Message("test", "message", "identity"))
locust/user/task.py CHANGED
@@ -88,7 +88,7 @@ def task(weight: TaskT | int = 1) -> TaskT | Callable[[TaskT], TaskT]:
88
88
  Check if task was used without parentheses (not called), like this::
89
89
 
90
90
  @task
91
- def my_task()
91
+ def my_task(self)
92
92
  pass
93
93
  """
94
94
  if callable(weight):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: locust
3
- Version: 2.20.1.dev11
3
+ Version: 2.20.1.dev22
4
4
  Summary: Developer friendly load testing framework
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://locust.io/
@@ -1,12 +1,12 @@
1
1
  locust/__init__.py,sha256=Q6sqz7YDUaMKPEqcDjWcXEFG2ilVRQR7kl0fG0yK_5A,1402
2
2
  locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
- locust/_version.py,sha256=wYlCPoTchI5nb5BztCyNACf-ezTTuirTF9CDA6jVogE,428
3
+ locust/_version.py,sha256=_-nimBgZv61fLaFWgwjuLbeFDBV2nYQpqbwrYtZnH-4,428
4
4
  locust/argument_parser.py,sha256=eCJM29OX7NcMROfNSxQm0uyNcEtml6Rj202t51TlovE,26418
5
5
  locust/clients.py,sha256=GJXTWcyBAepE6O-o-V92WboV8XKOXxWR-AixlcL74_w,14768
6
- locust/debug.py,sha256=pEnZ74679vCdDODEMTNvjYcVdWCe4sWolHDJvdXh9dU,4818
6
+ locust/debug.py,sha256=Rq0Wjs0esvjevAiUb04QhkLeClldwFvm5cj0aDl40dE,5063
7
7
  locust/dispatch.py,sha256=nVWXBkUzpqsVeVp5sw3sYSjR1dD5AAUiFLqutqsrlm4,18634
8
8
  locust/env.py,sha256=RntbYEcxP95Lrv80silTHI9qBthjdgz7OYH_HiM6s7U,11429
9
- locust/event.py,sha256=On9fb-FL9GxTDsgd8yApUoPoe2fShyPm2a3_9JrrobA,7453
9
+ locust/event.py,sha256=5NmOGPuYP89Wz8UjF9QRVx4N8GPuAlOrbtQWOLBmTH8,7671
10
10
  locust/exception.py,sha256=aGCx5TQmkYZn8P_uDD3Z4ZwxxRoA7R3ml0WJO-nHgFQ,1942
11
11
  locust/html.py,sha256=2mp33VdzqYHaugas3nGtW-ypWRLzGyhPYwin6HFkA98,5717
12
12
  locust/input_events.py,sha256=ARmzf5K_t4OnsNilkx0adDnNqvU9-NxtQvKOOjwgA_A,3048
@@ -21,7 +21,7 @@ locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  locust/contrib/fasthttp.py,sha256=qAEW7EwLot605rm1irLSuGA3TixvfioNYnKsq2PolWY,26534
22
22
  locust/rpc/__init__.py,sha256=nVGoHWFQxZjnhCDWjbgXIbmFbN9sizAjkhvSs9_642c,58
23
23
  locust/rpc/protocol.py,sha256=AGFtveF7-_i5ipsRYhT-ily4blxnjZ3FXeIL6ZabO4c,1285
24
- locust/rpc/zmqrpc.py,sha256=zG6hli3RouftrI28XqAlHtZ-UUSM9Wn41HkY9cKgAU4,2591
24
+ locust/rpc/zmqrpc.py,sha256=r4k7ALZwBUHcPuFbfa3nYf-zsi8Gfaj8jHnrk4zfmgc,2635
25
25
  locust/static/chart.js,sha256=Aue4SxJZhv9I3k0Nr2uXTrdrLxsrX7x_a0d4u3a1e_Q,4796
26
26
  locust/static/echarts.common.min.js,sha256=2h6zIZeHk-eGAiC-qYvxv7uW5S1HcyM72K5FbcVhky4,620458
27
27
  locust/static/jquery-1.11.3.min.js,sha256=7LkWEzqTdpEfELxcZZlS6wAx5Ff13zZ83lYO2_ujj7g,95957
@@ -52,7 +52,7 @@ locust/test/fake_module1_for_env_test.py,sha256=dzGYWCr1SSkd8Yyo68paUNrCNW7YY_Qg
52
52
  locust/test/fake_module2_for_env_test.py,sha256=dzGYWCr1SSkd8Yyo68paUNrCNW7YY_QgjRb7sM37gG0,164
53
53
  locust/test/mock_locustfile.py,sha256=N9sGjW-BmJ-J_x-5bEOR82VQ0DhR1hki313BHPOWq4g,1273
54
54
  locust/test/mock_logging.py,sha256=9KC_YXa0DvF44lvpDnWhjV0GLrtwtt2SxZIzM6sJGzU,783
55
- locust/test/test_debugging.py,sha256=_2by3ejG4Ujx8tz3-OOXiRBJzjwouS-jznKg5MZuGvk,963
55
+ locust/test/test_debugging.py,sha256=b-ekJpcwVWYlmIizdZYpbk1RMzrWPilM_iyzhb9tMvc,1069
56
56
  locust/test/test_dispatch.py,sha256=z94qj0exsIqtPl_TAx3vvBGxVBQoLovWcUPQfNulVO8,166172
57
57
  locust/test/test_env.py,sha256=Mp3EKVAjC84j57_yp7Gq67Q5TFyEOSQJ-mZyis_vt1c,6126
58
58
  locust/test/test_fasthttp.py,sha256=IIwyIIQIk8o_Hkyhg55Ff6NHF3hwXRBQJdhxNM8oEns,29886
@@ -73,13 +73,13 @@ locust/test/test_users.py,sha256=MErMCsEsHNALBj-GHcWjhZW5oMIoE4mbQW9dWqDHDQc,213
73
73
  locust/test/test_util.py,sha256=-wwdxyf1sqKVV_R2wDFZlp56ghBDkbS-leBEfjhxbMQ,1228
74
74
  locust/test/test_wait_time.py,sha256=9Qw48gGuJYpeb_0lr-bwuH3TjA4v2UQ1yDPZfUAjXX0,2353
75
75
  locust/test/test_web.py,sha256=I5Knomt9JQ1YSdiO2dyfVUDFkhOCuVey_R9_J0Qoy-s,48092
76
- locust/test/test_zmqrpc.py,sha256=JQ0iYWJoQb2JeS6EMvh_sOaG_sNjjXfT4V5RfsRnxlQ,2065
76
+ locust/test/test_zmqrpc.py,sha256=ETSahaxHG5snJAeTqQevPc9tuqpmOMBaKpZxPfwxh_I,2171
77
77
  locust/test/testcases.py,sha256=DkrP1mV5DX42kruPxAVj-dGLXq-XAy3WtEslDE69vlA,6979
78
78
  locust/test/util.py,sha256=LmxhmhLeXlsHnj1fPyesunHz5yqC9o0-UqOug5VBw14,2667
79
79
  locust/user/__init__.py,sha256=u5wggKl1tLRFlO66xbyVoQAHrbRRfEE7bFuY1AmUZOY,71
80
80
  locust/user/inspectuser.py,sha256=oKJEVWrFtNaPsZJRaNm3gbR0LyjVYPHtnrHjgtdJU1w,2641
81
81
  locust/user/sequential_taskset.py,sha256=6oaUz64xS13cpAgO--HxeMgn2N98DPpylUHqJ8H1v80,2542
82
- locust/user/task.py,sha256=cGlBXak2pqwHs_DDy-ehjTcwHaAFxP7uR8v05NQGNQ0,16780
82
+ locust/user/task.py,sha256=ER73Ai2IJ50eQZxb0u8ziLAFiQ3QqYwFIaIjDJpGc58,16784
83
83
  locust/user/users.py,sha256=lZtUojQoimuIh2hqEnf9clj58U22n7OnpiCYzDu_dtw,9737
84
84
  locust/user/wait_time.py,sha256=bGRKMVx4lom75sX3POYJUa1CPeME2bEAXG6CEgxSO5U,2675
85
85
  locust/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -94,9 +94,9 @@ locust/webui/dist/report.html,sha256=Vyi9LIAjBNiAsvn6LVFkdAZ9R4Fa8UjHnqscjAeOFp8
94
94
  locust/webui/dist/assets/favicon.ico,sha256=IUl-rYqfpHdV38e-s0bkmFIeLS-n3Ug0DQxk-h202hI,8348
95
95
  locust/webui/dist/assets/index-01afe4fa.js,sha256=uXPULlueC1FWZnTAMk7oA0wCSeY7xtNbxxycrIVvEGQ,1627703
96
96
  locust/webui/dist/assets/logo.png,sha256=lPCYhpDsPXYY3gUMlq3bzABI5WBtdBOvtay8R9hRFv4,2943
97
- locust-2.20.1.dev11.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
98
- locust-2.20.1.dev11.dist-info/METADATA,sha256=8ruAciL-9y07mSXyl5RHqpGhYEk6WS1k7Ky17ETolhI,7395
99
- locust-2.20.1.dev11.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
100
- locust-2.20.1.dev11.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
101
- locust-2.20.1.dev11.dist-info/top_level.txt,sha256=XSsjgPA8Ggf9TqKVbkwSqZFuPlZ085X13M9orDycE20,7
102
- locust-2.20.1.dev11.dist-info/RECORD,,
97
+ locust-2.20.1.dev22.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
98
+ locust-2.20.1.dev22.dist-info/METADATA,sha256=QGSjCdTlldnK_UZmXiEU_M2cyrPscZKFCd4VFfFPYM8,7395
99
+ locust-2.20.1.dev22.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
100
+ locust-2.20.1.dev22.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
101
+ locust-2.20.1.dev22.dist-info/top_level.txt,sha256=XSsjgPA8Ggf9TqKVbkwSqZFuPlZ085X13M9orDycE20,7
102
+ locust-2.20.1.dev22.dist-info/RECORD,,