locust 2.31.7.dev2__py3-none-any.whl → 2.31.7.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 CHANGED
@@ -14,7 +14,7 @@ __version_tuple__: VERSION_TUPLE
14
14
  version_tuple: VERSION_TUPLE
15
15
 
16
16
 
17
- __version__ = "2.31.7.dev2"
17
+ __version__ = "2.31.7.dev8"
18
18
  version = __version__
19
- __version_tuple__ = (2, 31, 7, "dev2")
19
+ __version_tuple__ = (2, 31, 7, "dev8")
20
20
  version_tuple = __version_tuple__
@@ -0,0 +1,41 @@
1
+ from locust import User, events
2
+
3
+ import time
4
+
5
+ from pymongo import MongoClient
6
+ from pymongo.errors import PyMongoError
7
+
8
+
9
+ class MongoDBClient(MongoClient):
10
+ def __init__(self, conn_string, db_name):
11
+ super().__init__(conn_string)
12
+ self.db = self.client[db_name]
13
+
14
+ def execute_query(self, collection_name, query):
15
+ start_time = time.time()
16
+ try:
17
+ collection = self.db[collection_name]
18
+ collection.find(query)
19
+
20
+ response_time = int((time.time() - start_time) * 1000)
21
+ events.request.fire(request_type="MONGODB", name="QUERY", response_time=response_time, response_length=0)
22
+ except PyMongoError as e:
23
+ response_time = int((time.time() - start_time) * 1000)
24
+ events.request.fire(
25
+ request_type="MONGODB",
26
+ name="QUERY",
27
+ response_time=response_time,
28
+ response_length=0,
29
+ exception=e,
30
+ )
31
+
32
+
33
+ class MongoDBUser(User):
34
+ abstract = True
35
+
36
+ def __init__(self, *args, **kwargs):
37
+ super().__init__(*args, **kwargs)
38
+ self.client = MongoDBClient(conn_string=self.conn_string, db_name=self.db_name)
39
+
40
+ def on_stop(self):
41
+ self.client.close()
locust/main.py CHANGED
@@ -199,6 +199,8 @@ def main():
199
199
  sys.exit(1)
200
200
 
201
201
  children = []
202
+ logger = logging.getLogger(__name__)
203
+ logger.info(f"Starting Locust {version}")
202
204
 
203
205
  if options.processes:
204
206
  if os.name == "nt":
@@ -298,7 +300,6 @@ def main():
298
300
 
299
301
  atexit.register(kill_workers, children)
300
302
 
301
- logger = logging.getLogger(__name__)
302
303
  greenlet_exception_handler = greenlet_exception_logger(logger)
303
304
 
304
305
  if options.stop_timeout:
@@ -686,7 +687,6 @@ See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-numb
686
687
  gevent.signal_handler(signal.SIGTERM, sig_term_handler)
687
688
 
688
689
  try:
689
- logger.info(f"Starting Locust {version}")
690
690
  if options.class_picker:
691
691
  logger.info("Locust is running with the UserClass Picker Enabled")
692
692
  if options.autostart and not options.headless:
locust/web.py CHANGED
@@ -135,6 +135,11 @@ class WebUI:
135
135
  # ensures static js files work on Windows
136
136
  mimetypes.add_type("application/javascript", ".js")
137
137
 
138
+ if self.web_login:
139
+ self._login_manager = LoginManager()
140
+ self._login_manager.init_app(self.app)
141
+ self._login_manager.login_view = "login"
142
+
138
143
  if environment.runner:
139
144
  self.update_template_args()
140
145
  if not delayed_start:
@@ -516,13 +521,14 @@ class WebUI:
516
521
  @property
517
522
  def login_manager(self):
518
523
  if self.web_login:
519
- login_manager = LoginManager()
520
- login_manager.init_app(self.app)
521
- login_manager.login_view = "login"
522
- return login_manager
524
+ return self._login_manager
523
525
 
524
526
  raise AttributeError("The login_manager is only available with --web-login.\n")
525
527
 
528
+ @login_manager.setter
529
+ def login_manager(self, value):
530
+ self._login_manager = value
531
+
526
532
  def start(self):
527
533
  self.greenlet = gevent.spawn(self.start_server)
528
534
  self.greenlet.link_exception(greenlet_exception_handler)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: locust
3
- Version: 2.31.7.dev2
3
+ Version: 2.31.7.dev8
4
4
  Summary: Developer-friendly load testing framework
5
5
  Home-page: https://locust.io/
6
6
  License: MIT
@@ -1,10 +1,11 @@
1
1
  locust/__init__.py,sha256=Jit8eNUrwuMLqavyFvMZr69e61DILq_KB4yT4MciScw,1681
2
2
  locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
- locust/_version.py,sha256=Q9T435Pf18gHeY2PAKDvCCK7vTh7paqLEkfA3cHQgJM,458
3
+ locust/_version.py,sha256=5behDNp5CPxZh_tx28MZyxeIXF11-3XxmeoDl1-z9x4,458
4
4
  locust/argument_parser.py,sha256=V0EI7vVvAFLX68ntjRg6qGr2hXSLJgQ0y743zvurwA8,29008
5
5
  locust/clients.py,sha256=XK-xabq2_5GZKMEjebDobvEjeBTtCs8h2EelL7s68Qs,19346
6
6
  locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  locust/contrib/fasthttp.py,sha256=qKgUyaH1AppEj64LzcMu67tzS5yls8mELkKs-N5pEtQ,28431
8
+ locust/contrib/mongodb.py,sha256=1seUYgJOaNKwybYOP9PUEVhgl8hGy-G33f8lFj3R8W8,1246
8
9
  locust/contrib/postgres.py,sha256=OuMWnGYN10K65Tq2axVESEW25Y0g5gJb0rK90jkcCJg,1230
9
10
  locust/debug.py,sha256=We6Z9W0btkKSc7PxWmrZx-xMynvOOsKhG6jmDgQin0g,5134
10
11
  locust/dispatch.py,sha256=prdwtb9EoN4A9klgiKgWuwQmvFB8hEuFHOK6ot62AJI,16202
@@ -14,7 +15,7 @@ locust/exception.py,sha256=jGgJ32ubuf4pWdlaVOkbh2Y0LlG0_DHi-lv3ib8ppOE,1791
14
15
  locust/html.py,sha256=ioHs8R6aqK_XCBSv4fOV90PYWv_MYQuW9Pl71R6EidM,3496
15
16
  locust/input_events.py,sha256=ZIyePyAMuA_YFYWg18g_pE4kwuQV3RbEB250MzXRwjY,3314
16
17
  locust/log.py,sha256=Wrkn0Ibugh5Sqjm4hGQ2-jUsy1tNMBdTctp4FyXQI24,3457
17
- locust/main.py,sha256=JpBo-TKv3O8mjh-6JPsF1jwLpJj9_UcRdBigGCK6OxU,29006
18
+ locust/main.py,sha256=kWiQkFjDQ3h4ou40PQhAjma9WyOTnflO9VaO0QNgyF4,29002
18
19
  locust/py.typed,sha256=gkWLl8yD4mIZnNYYAIRM8g9VarLvWmTAFeUfEbxJLBw,65
19
20
  locust/rpc/__init__.py,sha256=nVGoHWFQxZjnhCDWjbgXIbmFbN9sizAjkhvSs9_642c,58
20
21
  locust/rpc/protocol.py,sha256=n-rb3GZQcAlldYDj4E4GuFGylYj_26GSS5U29meft5Y,1282
@@ -38,7 +39,7 @@ locust/util/load_locustfile.py,sha256=hn70KcIG8jHmZyuKv2pcEmwgWtOEu24Efeji1KRYNU
38
39
  locust/util/rounding.py,sha256=5haxR8mKhATqag6WvPby-MSRRgIw5Ob6thbyvMYZM7o,92
39
40
  locust/util/timespan.py,sha256=Y0LtnhUq2Mq19p04u0XtBlYQ_-S2cRvwRdgru8W9WhA,986
40
41
  locust/util/url.py,sha256=s_W2PCxvxTWxWX0yUvp-8VBuQm881KwI5X9iifogZG4,321
41
- locust/web.py,sha256=figneTKyRa95SUii3k4OQI_oQOfG3wQqQpOhOjKxxXw,27671
42
+ locust/web.py,sha256=wwCIu2lCYGftuAwYZ2KXIXkkWGdgG0dDS5q3Tk6QEu0,27822
42
43
  locust/webui/dist/assets/favicon-dark.png,sha256=6zVkRtiRfU45qQGvEhf1cq2nNauFs_JW5SI79wT0YkM,2437
43
44
  locust/webui/dist/assets/favicon-light.png,sha256=VdG2GZyeTCOML7xfievupBP4EhmHoUqlVCw-tXqkvxU,2468
44
45
  locust/webui/dist/assets/index-DQd3Odi5.js,sha256=KSEsSxvrUSsT08C4AcXte5FdBqbQlsFeRfVCdw57h8g,1671822
@@ -46,8 +47,8 @@ locust/webui/dist/auth.html,sha256=lFK2hUASKiH4veqEKI8SVpVcv75L07iLgdsx1usfPRo,6
46
47
  locust/webui/dist/index.html,sha256=w1ar7WpzWHSVkgoL5n6IPCOvAgWfmOChoYofr2xsey0,654
47
48
  locust/webui/dist/report.html,sha256=bjpe_eyweJLqLk7REsQOdOPp7e8PoGRajD5P8gIJeNE,1472409
48
49
  poetry.lock,sha256=SYexv51dGkbiljj9e0x0LVzQ0-gxKn31hwhFTO2t298,205000
49
- locust-2.31.7.dev2.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
50
- locust-2.31.7.dev2.dist-info/METADATA,sha256=C92_BE2_cXGWCay9DKJEkvaJ2_e2AhAr7fmIT7gCMes,7724
51
- locust-2.31.7.dev2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
52
- locust-2.31.7.dev2.dist-info/entry_points.txt,sha256=RhIxlLwU_Ae_WjimS5COUDLagdCh6IOMyLtgaQxNmlM,43
53
- locust-2.31.7.dev2.dist-info/RECORD,,
50
+ locust-2.31.7.dev8.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
51
+ locust-2.31.7.dev8.dist-info/METADATA,sha256=e0BVX77F-xZXlJ7TwxTAydmZyZZfgOmZRzOETnnPb1g,7724
52
+ locust-2.31.7.dev8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
53
+ locust-2.31.7.dev8.dist-info/entry_points.txt,sha256=RhIxlLwU_Ae_WjimS5COUDLagdCh6IOMyLtgaQxNmlM,43
54
+ locust-2.31.7.dev8.dist-info/RECORD,,