locust 2.31.4.dev27__py3-none-any.whl → 2.31.4.dev44__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.4.dev27"
17
+ __version__ = "2.31.4.dev44"
18
18
  version = __version__
19
- __version_tuple__ = (2, 31, 4, "dev27")
19
+ __version_tuple__ = (2, 31, 4, "dev44")
20
20
  version_tuple = __version_tuple__
@@ -0,0 +1,45 @@
1
+ from locust import User, events
2
+
3
+ import time
4
+
5
+ import psycopg
6
+
7
+
8
+ class PostgresClient:
9
+ def __init__(self, conn_string):
10
+ self.connection = psycopg.connect(conn_string)
11
+
12
+ def execute_query(self, query):
13
+ start_time = time.time()
14
+ try:
15
+ self.connection.execute(query)
16
+ response_time = int((time.time() - start_time) * 1000)
17
+ events.request.fire(
18
+ request_type="postgres_success",
19
+ name="execute_query",
20
+ response_time=response_time,
21
+ response_length=0,
22
+ )
23
+ except Exception as e:
24
+ response_time = int((time.time() - start_time) * 1000)
25
+ events.request.fire(
26
+ request_type="postgres_failure",
27
+ name="execute_query",
28
+ response_time=response_time,
29
+ response_length=0,
30
+ exception=e,
31
+ )
32
+
33
+ def close(self):
34
+ self.connection.close()
35
+
36
+
37
+ class PostgresUser(User):
38
+ abstract = True
39
+
40
+ def __init__(self, *args, **kwargs):
41
+ super().__init__(*args, **kwargs)
42
+ self.client = PostgresClient(conn_string=self.conn_string)
43
+
44
+ def on_stop(self):
45
+ self.client.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: locust
3
- Version: 2.31.4.dev27
3
+ Version: 2.31.4.dev44
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=vlPR-iGGBjEn1JWFNsWXzhNKIY5k4d442zYGhJ9qUk4,460
3
+ locust/_version.py,sha256=0nomho3opGSVYhW7so7EWRipkaKCG-n_N4eTTXuqwPU,460
4
4
  locust/argument_parser.py,sha256=FMEWKC5OMVzpliRYa6KJvmpMRFvtlJFoVKxyW9_NJuc,29012
5
5
  locust/clients.py,sha256=OHPv6hBAt4gt3HI67yqyT1qrSsF8uMdCwIRu0kIsRWI,19491
6
6
  locust/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  locust/contrib/fasthttp.py,sha256=1hR2WK-3ACGVsU6Fu4Z4KucVzL1LXMLG6k54KeZdt78,28509
8
+ locust/contrib/postgres.py,sha256=OuMWnGYN10K65Tq2axVESEW25Y0g5gJb0rK90jkcCJg,1230
8
9
  locust/debug.py,sha256=We6Z9W0btkKSc7PxWmrZx-xMynvOOsKhG6jmDgQin0g,5134
9
10
  locust/dispatch.py,sha256=esAp4k8j1zQ8pX2j01UiYUmWS1-9r-XhQvylYyyFeR0,16228
10
11
  locust/env.py,sha256=e5FNcpoftv8G0D86cR1t1cXatumBmCIDA7DbR1JjOSw,13000
@@ -44,8 +45,8 @@ locust/webui/dist/assets/index-BTVvoV6z.js,sha256=9_80rFccPA6Zj0O0Pltwe-ZlI0nxOl
44
45
  locust/webui/dist/auth.html,sha256=ZCBJy5NW6FPqa4V0Bq1lHzx26aSaF6UV21ffS0LH1Og,648
45
46
  locust/webui/dist/index.html,sha256=JVKEwn_J1HUJvBJa-9R1JNBpoXBimWMjfEoXdyXJogo,654
46
47
  locust/webui/dist/report.html,sha256=CPuv-WOa0QbAeJB57YapUdeb_hwoc65fe9M7N9GDLDs,1472463
47
- locust-2.31.4.dev27.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
48
- locust-2.31.4.dev27.dist-info/METADATA,sha256=O6_jCjsgMvrs3qAJNNPckB1SDdptkhPYT_oie3NwEac,7679
49
- locust-2.31.4.dev27.dist-info/WHEEL,sha256=HBsDV7Hj4OTiS1GX6ua7iQXUQTB9UHftbBxr7Q8Xm9c,110
50
- locust-2.31.4.dev27.dist-info/entry_points.txt,sha256=RhIxlLwU_Ae_WjimS5COUDLagdCh6IOMyLtgaQxNmlM,43
51
- locust-2.31.4.dev27.dist-info/RECORD,,
48
+ locust-2.31.4.dev44.dist-info/LICENSE,sha256=78XGpIn3fHVBfaxlPNUfjVufSN7QsdhpJMRJHv2AFpo,1095
49
+ locust-2.31.4.dev44.dist-info/METADATA,sha256=faH7qAC7irfbTul1KToL5q6qF070Z0CJiWFK6VLwdTk,7679
50
+ locust-2.31.4.dev44.dist-info/WHEEL,sha256=HBsDV7Hj4OTiS1GX6ua7iQXUQTB9UHftbBxr7Q8Xm9c,110
51
+ locust-2.31.4.dev44.dist-info/entry_points.txt,sha256=RhIxlLwU_Ae_WjimS5COUDLagdCh6IOMyLtgaQxNmlM,43
52
+ locust-2.31.4.dev44.dist-info/RECORD,,