latch-postgres 0.1.20__tar.gz → 0.1.21__tar.gz
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-0.1.20 → latch_postgres-0.1.21}/PKG-INFO +1 -1
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/pyproject.toml +1 -1
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/src/latch_postgres/postgres.py +7 -5
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/.envrc +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/.gitignore +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/Justfile +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/LICENSE +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/README.md +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/src/latch_postgres/__init__.py +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/src/latch_postgres/py.typed +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/src/latch_postgres/retries.py +0 -0
- {latch_postgres-0.1.20 → latch_postgres-0.1.21}/uv.lock +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import functools
|
|
3
3
|
import random
|
|
4
|
-
from collections.abc import AsyncGenerator, Awaitable, Callable, Iterable
|
|
4
|
+
from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Iterable
|
|
5
5
|
from contextlib import asynccontextmanager
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from datetime import timedelta
|
|
@@ -52,6 +52,8 @@ from typing_extensions import Self
|
|
|
52
52
|
|
|
53
53
|
from latch_postgres.retries import CABackoff
|
|
54
54
|
|
|
55
|
+
YT = TypeVar("YT")
|
|
56
|
+
ST = TypeVar("ST")
|
|
55
57
|
T = TypeVar("T")
|
|
56
58
|
|
|
57
59
|
tracer = get_tracer(__name__)
|
|
@@ -455,10 +457,10 @@ def pg_error_to_dict(x: PGError, *, short: bool = False):
|
|
|
455
457
|
|
|
456
458
|
|
|
457
459
|
def with_conn_retry(
|
|
458
|
-
f: Callable[Concatenate[LatchAsyncConnection[Any], P],
|
|
460
|
+
f: Callable[Concatenate[LatchAsyncConnection[Any], P], Coroutine[YT, ST, T]],
|
|
459
461
|
pool: AsyncConnectionPool,
|
|
460
462
|
db_config: PostgresConnectionConfig,
|
|
461
|
-
) -> Callable[P,
|
|
463
|
+
) -> Callable[P, Coroutine[YT, ST, T]]:
|
|
462
464
|
@functools.wraps(f)
|
|
463
465
|
async def inner(*args: P.args, **kwargs: P.kwargs):
|
|
464
466
|
with tracer.start_as_current_span("database session") as s:
|
|
@@ -585,8 +587,8 @@ def with_conn_retry(
|
|
|
585
587
|
def get_with_conn_retry(
|
|
586
588
|
pool: AsyncConnectionPool, db_config: PostgresConnectionConfig
|
|
587
589
|
) -> Callable[
|
|
588
|
-
[Callable[Concatenate[LatchAsyncConnection[Any], P],
|
|
589
|
-
Callable[P,
|
|
590
|
+
[Callable[Concatenate[LatchAsyncConnection[Any], P], Coroutine[YT, ST, T]]],
|
|
591
|
+
Callable[P, Coroutine[YT, ST, T]],
|
|
590
592
|
]:
|
|
591
593
|
return functools.partial(with_conn_retry, pool=pool, db_config=db_config)
|
|
592
594
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|