latch-postgres 0.1.17__py3-none-any.whl → 0.1.19__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.
- latch_postgres/postgres.py +39 -38
- {latch_postgres-0.1.17.dist-info → latch_postgres-0.1.19.dist-info}/METADATA +5 -3
- latch_postgres-0.1.19.dist-info/RECORD +8 -0
- {latch_postgres-0.1.17.dist-info → latch_postgres-0.1.19.dist-info}/WHEEL +1 -1
- latch_postgres-0.1.17.dist-info/RECORD +0 -8
- {latch_postgres-0.1.17.dist-info → latch_postgres-0.1.19.dist-info}/LICENSE +0 -0
latch_postgres/postgres.py
CHANGED
|
@@ -500,47 +500,48 @@ def with_conn_retry(
|
|
|
500
500
|
while True:
|
|
501
501
|
try:
|
|
502
502
|
async with pool.connection() as conn:
|
|
503
|
-
|
|
503
|
+
with tracer.start_as_current_span("connection acquired"):
|
|
504
|
+
assert isinstance(conn, LatchAsyncConnection)
|
|
504
505
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
506
|
+
backoff = CABackoff(
|
|
507
|
+
db_config.tx_retries.delay_quant,
|
|
508
|
+
db_config.tx_retries.max_wait_time,
|
|
509
|
+
)
|
|
510
|
+
while True:
|
|
511
|
+
try:
|
|
512
|
+
res = await f(conn, *args, **kwargs)
|
|
513
|
+
# Commit here so we can retry if it fails
|
|
514
|
+
# Otherwise the context manager will commit and fail
|
|
515
|
+
await conn.commit()
|
|
516
|
+
return res
|
|
517
|
+
except (
|
|
518
|
+
# Class 40 - Transaction Rollback
|
|
519
|
+
SerializationFailure,
|
|
520
|
+
DeadlockDetected,
|
|
521
|
+
) as e:
|
|
522
|
+
# Retry with the same connection
|
|
523
|
+
delay = backoff.retry()
|
|
524
|
+
|
|
525
|
+
if delay is None:
|
|
526
|
+
raise e
|
|
527
|
+
|
|
528
|
+
s.add_event(
|
|
529
|
+
"transaction retry",
|
|
530
|
+
{
|
|
531
|
+
"db.retry.count": retries,
|
|
532
|
+
"db.retry.accum_retry_time": str(
|
|
533
|
+
backoff.acc_wait_time
|
|
534
|
+
),
|
|
535
|
+
"db.retry.delay": str(delay),
|
|
536
|
+
}
|
|
537
|
+
| dict_to_attrs(
|
|
538
|
+
pg_error_to_dict(e, short=True),
|
|
539
|
+
"db.retry.reason",
|
|
533
540
|
),
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
| dict_to_attrs(
|
|
537
|
-
pg_error_to_dict(e, short=True),
|
|
538
|
-
"db.retry.reason",
|
|
539
|
-
),
|
|
540
|
-
)
|
|
541
|
+
)
|
|
541
542
|
|
|
542
|
-
|
|
543
|
-
|
|
543
|
+
await conn.rollback()
|
|
544
|
+
await asyncio.sleep(delay)
|
|
544
545
|
except (SerializationFailure, DeadlockDetected):
|
|
545
546
|
# todo(maximsmol): should be unnecessary if the list below is precise enough
|
|
546
547
|
raise
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: latch-postgres
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
4
4
|
Summary: Postges wrapper for latch python backend services
|
|
5
5
|
License: CC0 1.0
|
|
6
6
|
Author: Max Smolin
|
|
@@ -9,8 +9,10 @@ Requires-Python: >=3.11,<4.0
|
|
|
9
9
|
Classifier: License :: Other/Proprietary License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
14
|
Requires-Dist: latch-config (>=0.1.6,<0.2.0)
|
|
13
|
-
Requires-Dist: latch-data-validation (>=0.1.
|
|
15
|
+
Requires-Dist: latch-data-validation (>=0.1.10,<0.2.0)
|
|
14
16
|
Requires-Dist: latch-o11y (>=0.1.4,<0.2.0)
|
|
15
17
|
Requires-Dist: opentelemetry-api (>=1.15.0,<2.0.0)
|
|
16
18
|
Requires-Dist: opentelemetry-sdk (>=1.15.0,<2.0.0)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
latch_postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
latch_postgres/postgres.py,sha256=tGUhVLq5J4tyNrKt4xiRf-RlkqFNrUZ9Jl7WEHLqIPQ,24845
|
|
3
|
+
latch_postgres/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
latch_postgres/retries.py,sha256=r5yH00fd_6EJNYFXAq3dAljJBphScpoeST-_oMvyj8Q,1308
|
|
5
|
+
latch_postgres-0.1.19.dist-info/LICENSE,sha256=wh3JZu6ITG7ceN-1g404ekupj5JXAw4pnQ_Qr4sJfew,7052
|
|
6
|
+
latch_postgres-0.1.19.dist-info/METADATA,sha256=fFn_TvOGV1kApPUiG9ow5gMgWQrMl3jVI2ZbNpQD_M0,869
|
|
7
|
+
latch_postgres-0.1.19.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
|
8
|
+
latch_postgres-0.1.19.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
latch_postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
latch_postgres/postgres.py,sha256=1eqzuFv7NCYOru6-mHcJNsyjASwPWL_9qHH86lEXb4g,24611
|
|
3
|
-
latch_postgres/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
latch_postgres/retries.py,sha256=r5yH00fd_6EJNYFXAq3dAljJBphScpoeST-_oMvyj8Q,1308
|
|
5
|
-
latch_postgres-0.1.17.dist-info/LICENSE,sha256=wh3JZu6ITG7ceN-1g404ekupj5JXAw4pnQ_Qr4sJfew,7052
|
|
6
|
-
latch_postgres-0.1.17.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
|
7
|
-
latch_postgres-0.1.17.dist-info/METADATA,sha256=3cpgB1eCGeZf3WXac7-dAdJU0Zpjf1YmELO7pDWatpg,766
|
|
8
|
-
latch_postgres-0.1.17.dist-info/RECORD,,
|
|
File without changes
|