locust 2.24.2.dev3__py3-none-any.whl → 2.24.2.dev8__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/runners.py +14 -6
- locust/test/test_runners.py +25 -0
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.dist-info}/METADATA +1 -1
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.dist-info}/RECORD +9 -9
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.dist-info}/LICENSE +0 -0
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.dist-info}/WHEEL +0 -0
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.dist-info}/entry_points.txt +0 -0
- {locust-2.24.2.dev3.dist-info → locust-2.24.2.dev8.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.24.2.
|
16
|
-
__version_tuple__ = version_tuple = (2, 24, 2, '
|
15
|
+
__version__ = version = '2.24.2.dev8'
|
16
|
+
__version_tuple__ = version_tuple = (2, 24, 2, 'dev8')
|
locust/runners.py
CHANGED
@@ -119,7 +119,7 @@ class Runner:
|
|
119
119
|
self.target_user_classes_count: dict[str, int] = {}
|
120
120
|
# target_user_count is set before the ramp-up/ramp-down occurs.
|
121
121
|
self.target_user_count: int = 0
|
122
|
-
self.custom_messages: dict[str, Callable] = {}
|
122
|
+
self.custom_messages: dict[str, tuple[Callable, bool]] = {}
|
123
123
|
|
124
124
|
self._users_dispatcher: UsersDispatcher | None = None
|
125
125
|
|
@@ -420,7 +420,7 @@ class Runner:
|
|
420
420
|
row["nodes"].add(node_id)
|
421
421
|
self.exceptions[key] = row
|
422
422
|
|
423
|
-
def register_message(self, msg_type: str, listener: Callable) -> None:
|
423
|
+
def register_message(self, msg_type: str, listener: Callable, concurrent=False) -> None:
|
424
424
|
"""
|
425
425
|
Register a listener for a custom message from another node
|
426
426
|
|
@@ -429,7 +429,7 @@ class Runner:
|
|
429
429
|
"""
|
430
430
|
if msg_type in self.custom_messages:
|
431
431
|
raise Exception(f"Tried to register listener method for {msg_type}, but it already had a listener!")
|
432
|
-
self.custom_messages[msg_type] = listener
|
432
|
+
self.custom_messages[msg_type] = (listener, concurrent)
|
433
433
|
|
434
434
|
|
435
435
|
class LocalRunner(Runner):
|
@@ -568,7 +568,7 @@ class LocalRunner(Runner):
|
|
568
568
|
"""
|
569
569
|
logger.debug("Running locally: sending %s message to self" % msg_type)
|
570
570
|
if msg_type in self.custom_messages:
|
571
|
-
listener = self.custom_messages[msg_type]
|
571
|
+
listener, concurrent = self.custom_messages[msg_type]
|
572
572
|
msg = Message(msg_type, data, "local")
|
573
573
|
listener(environment=self.environment, msg=msg)
|
574
574
|
else:
|
@@ -1139,7 +1139,11 @@ class MasterRunner(DistributedRunner):
|
|
1139
1139
|
f"Received {msg.type} message from worker {msg.node_id} (index {self.get_worker_index(msg.node_id)})"
|
1140
1140
|
)
|
1141
1141
|
try:
|
1142
|
-
self.custom_messages[msg.type]
|
1142
|
+
listener, concurrent = self.custom_messages[msg.type]
|
1143
|
+
if not concurrent:
|
1144
|
+
listener(environment=self.environment, msg=msg)
|
1145
|
+
else:
|
1146
|
+
gevent.spawn(listener, self.environment, msg)
|
1143
1147
|
except Exception:
|
1144
1148
|
logging.error(f"Uncaught exception in handler for {msg.type}\n{traceback.format_exc()}")
|
1145
1149
|
|
@@ -1393,7 +1397,11 @@ class WorkerRunner(DistributedRunner):
|
|
1393
1397
|
self.last_heartbeat_timestamp = time.time()
|
1394
1398
|
elif msg.type in self.custom_messages:
|
1395
1399
|
logger.debug("Received %s message from master" % msg.type)
|
1396
|
-
self.custom_messages[msg.type]
|
1400
|
+
listener, concurrent = self.custom_messages[msg.type]
|
1401
|
+
if not concurrent:
|
1402
|
+
listener(environment=self.environment, msg=msg)
|
1403
|
+
else:
|
1404
|
+
gevent.spawn(listener, self.environment, msg)
|
1397
1405
|
else:
|
1398
1406
|
logger.warning(f"Unknown message type received: {msg.type}")
|
1399
1407
|
|
locust/test/test_runners.py
CHANGED
@@ -606,6 +606,31 @@ class TestLocustRunner(LocustRunnerTestCase):
|
|
606
606
|
self.assertTrue(test_custom_msg[0])
|
607
607
|
self.assertEqual(123, test_custom_msg_data[0]["test_data"])
|
608
608
|
|
609
|
+
def test_concurrent_custom_message(self):
|
610
|
+
class MyUser(User):
|
611
|
+
wait_time = constant(1)
|
612
|
+
|
613
|
+
@task
|
614
|
+
def my_task(self):
|
615
|
+
pass
|
616
|
+
|
617
|
+
test_custom_msg = [False]
|
618
|
+
test_custom_msg_data = [{}]
|
619
|
+
|
620
|
+
def on_custom_msg(msg, **kw):
|
621
|
+
test_custom_msg[0] = True
|
622
|
+
test_custom_msg_data[0] = msg.data
|
623
|
+
|
624
|
+
environment = Environment(user_classes=[MyUser])
|
625
|
+
runner = LocalRunner(environment)
|
626
|
+
|
627
|
+
runner.register_message("test_custom_msg", on_custom_msg, concurrent=True)
|
628
|
+
runner.send_message("test_custom_msg", {"test_data": 123})
|
629
|
+
|
630
|
+
gevent.sleep(0.5)
|
631
|
+
self.assertTrue(test_custom_msg[0])
|
632
|
+
self.assertEqual(123, test_custom_msg_data[0]["test_data"])
|
633
|
+
|
609
634
|
def test_undefined_custom_message(self):
|
610
635
|
class MyUser(User):
|
611
636
|
wait_time = constant(1)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
locust/__init__.py,sha256=g6oA-Ba_hs3gLWVf5MKJ1mvfltI8MFnDWG8qslqm8yg,1402
|
2
2
|
locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
|
3
|
-
locust/_version.py,sha256=
|
3
|
+
locust/_version.py,sha256=bAEcz2Qz2n-X-EUhNpeiWYbH2b8WU7ifl2M-cBOmoqs,426
|
4
4
|
locust/argument_parser.py,sha256=iDnCJNs9ySKOrIn6xZjZXN3YIelOPC1FSR2MK5nEHP4,31973
|
5
5
|
locust/clients.py,sha256=o3G9welWb-zhgDUM5TKnMVFMJckr_m0FI8Dxn3OtBUA,14810
|
6
6
|
locust/debug.py,sha256=We6Z9W0btkKSc7PxWmrZx-xMynvOOsKhG6jmDgQin0g,5134
|
@@ -13,7 +13,7 @@ locust/input_events.py,sha256=QBO6Kb0bmNLZHaIvcBORk57CvCJHAYVB5ILfpV8Lrfc,3292
|
|
13
13
|
locust/log.py,sha256=2IVp9YL4ZPfWdj3sBFuOHfgneg3g7m7tUGR-sy2s3E8,3155
|
14
14
|
locust/main.py,sha256=8DvGTqRXxFZu6Z_rmPRJt6Ox-2cCkxks9j-iZGRrQiU,28866
|
15
15
|
locust/py.typed,sha256=gkWLl8yD4mIZnNYYAIRM8g9VarLvWmTAFeUfEbxJLBw,65
|
16
|
-
locust/runners.py,sha256=
|
16
|
+
locust/runners.py,sha256=zoepC10fGP248Y4SyoHFDKuGcYQHV9Vi3brpPSKn5zg,67851
|
17
17
|
locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
|
18
18
|
locust/stats.py,sha256=BXvAybKiqI6QF5THdnk-fWkL-FiZKwrAm2W8KzkTchg,46118
|
19
19
|
locust/web.py,sha256=DVcx53VXApAc6kFfG7so2_kB_qqcw7ojKpBd-dJoijU,28267
|
@@ -64,7 +64,7 @@ locust/test/test_log.py,sha256=YPY6vgTAy1KaNU2qoVvQrTH5x_mzRrljEHrkSBy3yxs,7553
|
|
64
64
|
locust/test/test_main.py,sha256=Fgvae1Nas7DyIlWmTjJ-2dhBZmVv2Pj9Cqa-r0Z4SN8,83712
|
65
65
|
locust/test/test_old_wait_api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
66
|
locust/test/test_parser.py,sha256=eV3HSKWkgr9wh87ZcO3-bt2sg8vYS99LnJ9yRCyMahE,18309
|
67
|
-
locust/test/test_runners.py,sha256=
|
67
|
+
locust/test/test_runners.py,sha256=6PDbv4Fyv6vLBJCl7ghEh_wGlFy80Ha8M0zixRvC2LM,159328
|
68
68
|
locust/test/test_sequential_taskset.py,sha256=QjVMWWfGHn9hU5AvPxRDU7Vo5DcVW1VkMVfDA0k9OPE,3398
|
69
69
|
locust/test/test_stats.py,sha256=g5WXKbKtjtPxR_Ixukz04wZUsEC7RkHx5hCNHzofob4,33928
|
70
70
|
locust/test/test_tags.py,sha256=mzhGLPMizSnSItTHLHizYvloxDfuIDAOgelwInyrf28,13138
|
@@ -95,9 +95,9 @@ locust/webui/dist/report.html,sha256=sOdZZVgZbqgu86BBCSQf3uQUYXgmgSnXF32JpnyAII8
|
|
95
95
|
locust/webui/dist/assets/favicon.ico,sha256=IUl-rYqfpHdV38e-s0bkmFIeLS-n3Ug0DQxk-h202hI,8348
|
96
96
|
locust/webui/dist/assets/index-941b6e82.js,sha256=G3n5R81Svt0HzbWaV3AV20jLWGLr4X50UZ-Adu2KcxU,1645614
|
97
97
|
locust/webui/dist/assets/logo.png,sha256=EIVPqr6wE_yqguHaqFHIsH0ZACLSrvNWyYO7PbyIj4w,19299
|
98
|
-
locust-2.24.2.
|
99
|
-
locust-2.24.2.
|
100
|
-
locust-2.24.2.
|
101
|
-
locust-2.24.2.
|
102
|
-
locust-2.24.2.
|
103
|
-
locust-2.24.2.
|
98
|
+
locust-2.24.2.dev8.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
|
99
|
+
locust-2.24.2.dev8.dist-info/METADATA,sha256=q562vjHBp2dCMS_AHdGaineLy2dSzHufvox5iVroO7g,7211
|
100
|
+
locust-2.24.2.dev8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
101
|
+
locust-2.24.2.dev8.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
|
102
|
+
locust-2.24.2.dev8.dist-info/top_level.txt,sha256=XSsjgPA8Ggf9TqKVbkwSqZFuPlZ085X13M9orDycE20,7
|
103
|
+
locust-2.24.2.dev8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|