altcodepro-polydb-python 2.3.29__py3-none-any.whl → 2.3.31__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: altcodepro-polydb-python
3
- Version: 2.3.29
3
+ Version: 2.3.31
4
4
  Summary: Production-ready multi-cloud database abstraction layer with connection pooling, retry logic, and thread safety
5
5
  Author: AltCodePro
6
6
  Project-URL: Homepage, https://github.com/altcodepro/polydb-python
@@ -1,4 +1,4 @@
1
- altcodepro_polydb_python-2.3.29.dist-info/licenses/LICENSE,sha256=9X8GLocsBwy-5aR5JGOt2SAMDDPs9Qv-YnqmHBHOXrw,1067
1
+ altcodepro_polydb_python-2.3.31.dist-info/licenses/LICENSE,sha256=9X8GLocsBwy-5aR5JGOt2SAMDDPs9Qv-YnqmHBHOXrw,1067
2
2
  polydb/PolyDB.py,sha256=MG7-nV59zDvrUQwXNEgV4eetHCeW9TYY9DQqtxu_r7k,23543
3
3
  polydb/__init__.py,sha256=d9KSz888A336904TPEjWPYBtyJLPB0lTdcaOnYp8byY,1535
4
4
  polydb/advanced_query.py,sha256=cxMB-EB-qT3bWXJlhmjnMCUtrzogORWyoEfS50Dy7go,4280
@@ -15,7 +15,7 @@ polydb/multitenancy.py,sha256=9kyY98RpKg8xDy9ejB_MyV_YzF7eZd4uxashw5S8vlg,6408
15
15
  polydb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  polydb/query.py,sha256=3oWgRXIYLItmd_R-7u78hCdUgUaoiFmjVg38vi2-rVA,6600
17
17
  polydb/registry.py,sha256=RD_elvFXcmhTdCyZDm2f3ej0elxqhArnSJ2aO9k5VCU,2352
18
- polydb/retry.py,sha256=OfmNglrmL6AQlJPmXNdy9A9lRkH0P-vZ5BUuMiUM__4,3795
18
+ polydb/retry.py,sha256=QduWwDyiU-dt1fHFQmm6ltbnaJY2460cDfQ7ZE8wjXs,4466
19
19
  polydb/schema.py,sha256=VrOayX6V6AD2Qh3-lm4ZVPTpI24e4V52IYheZf2rNQ4,5812
20
20
  polydb/security.py,sha256=9ju-hc6Y1sxobCoV_mZ3ZWroUD73LodyTLVMhY_HeKU,16360
21
21
  polydb/types.py,sha256=XB_85Un8_aWt4dSfpjIGotHbK3KBY2WurQGXr9EOxWY,2992
@@ -36,7 +36,7 @@ polydb/adapters/GCPFilestoreAdapter.py,sha256=yjFQQwsWYWc8mo8XwMViVTWb5_D--xAyTM
36
36
  polydb/adapters/GCPPubSubAdapter.py,sha256=7XNots2VA0ReEDku-rjg-OTYmftIpx5UgnXYDdXNkOo,8692
37
37
  polydb/adapters/GCPStorageAdapter.py,sha256=9yS1Jhcn5_rCRdZ5uOqcRW6Ba-UNb6VOYpwENP-C6Qk,7133
38
38
  polydb/adapters/MongoDBAdapter.py,sha256=Ak8q_qeAaUTe0Yc2oEefmAbzoODjTWVZQOirW-seBQU,7574
39
- polydb/adapters/PostgreSQLAdapter.py,sha256=lUe65kpJkTu6R1Tc1zgl63Fa1PI44UVbWRTKRUSSGak,36579
39
+ polydb/adapters/PostgreSQLAdapter.py,sha256=9VI4-JOdDPeCDba8lRar4RkVMuF0bAymkvSTE3HILjs,38239
40
40
  polydb/adapters/S3Adapter.py,sha256=5R0zHAL2SkGFjp1L3bp-IU468bXYdSf6nKx974MN104,7586
41
41
  polydb/adapters/S3CompatibleAdapter.py,sha256=jpafqbAjA8-irdXBrfXa1QJySIzrcUQ6UrFt5h5FAEc,7006
42
42
  polydb/adapters/SQSAdapter.py,sha256=1vfbNoqIDy-b8t2xcxy91SoxSYBPFDfUh7yCQWxdS84,5778
@@ -60,7 +60,7 @@ polydb/observability/logging.py,sha256=gv1SshNjaSkmR98Uv7Qbwq3gkeQUzVCA4ichqHKL6
60
60
  polydb/services/__init__.py,sha256=nMolMXzmhejRSm7f42kU9fCHF0GIpqpejN2kywuBsUQ,241
61
61
  polydb/services/compliance_service.py,sha256=-0ncX7PrXy4-NuyWXIv65cLUsqz0jXzb3LtsD8rlrXE,4983
62
62
  polydb/services/security_service.py,sha256=q7GzK6sbMnBBsc4fuL4oXTd-ui2b-MYQyrWTBvdVNSk,5062
63
- altcodepro_polydb_python-2.3.29.dist-info/METADATA,sha256=7bWio-A4c46Q0twrvo3OX7m5s3wYBpfR0NajgheWDgQ,12359
64
- altcodepro_polydb_python-2.3.29.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
65
- altcodepro_polydb_python-2.3.29.dist-info/top_level.txt,sha256=WgLFWJoYjUhwvyPxJFl6jYLrVFuBJDX3OABf4ocwk_E,7
66
- altcodepro_polydb_python-2.3.29.dist-info/RECORD,,
63
+ altcodepro_polydb_python-2.3.31.dist-info/METADATA,sha256=mEh53S4z1JD9K0ZMj4b4L1EOPOZji-fSz4vCS5BHCjQ,12359
64
+ altcodepro_polydb_python-2.3.31.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
65
+ altcodepro_polydb_python-2.3.31.dist-info/top_level.txt,sha256=WgLFWJoYjUhwvyPxJFl6jYLrVFuBJDX3OABf4ocwk_E,7
66
+ altcodepro_polydb_python-2.3.31.dist-info/RECORD,,
@@ -76,7 +76,7 @@ class PostgreSQLAdapter:
76
76
  def _initialize_pool(self):
77
77
  try:
78
78
  import psycopg2.pool
79
- from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
79
+ from urllib.parse import urlparse, parse_qs, quote, urlencode, urlunparse
80
80
 
81
81
  dsn = self.connection_string
82
82
  if "postgresql://" in dsn:
@@ -87,8 +87,33 @@ class PostgreSQLAdapter:
87
87
  query.setdefault("keepalives_idle", ["30"])
88
88
  query.setdefault("keepalives_interval", ["10"])
89
89
  query.setdefault("keepalives_count", ["5"])
90
+ # connect_timeout only bounds the initial handshake; keepalives
91
+ # only detect a dead *idle* connection. Neither bounds a query
92
+ # that's already in flight and stalls mid-response (packet
93
+ # loss / a silently-dropped connection somewhere on the path
94
+ # to a remote DB) -- that shows up as libpq's own "could not
95
+ # receive data from server: Operation timed out / SSL SYSCALL
96
+ # error", and without a bound the client can block on that
97
+ # recv() for a very long time (Python can't interrupt a
98
+ # blocking C-level syscall, so even Ctrl+C doesn't land until
99
+ # it returns). tcp_user_timeout bounds unacknowledged data at
100
+ # the OS/TCP level; statement_timeout bounds how long Postgres
101
+ # itself will run a query before cancelling it server-side.
102
+ query.setdefault(
103
+ "tcp_user_timeout",
104
+ [os.getenv("POSTGRES_TCP_USER_TIMEOUT_MS", "20000")],
105
+ )
106
+ query.setdefault(
107
+ "options",
108
+ [f"-c statement_timeout={os.getenv('POSTGRES_STATEMENT_TIMEOUT_MS', '20000')}"],
109
+ )
90
110
 
91
- new_query = urlencode(query, doseq=True)
111
+ # quote_via=quote, not the default quote_plus: libpq's URI
112
+ # parser percent-decodes query values but treats "+" as a
113
+ # literal plus, so form-encoding the space in
114
+ # "-c statement_timeout=..." makes the server see the option
115
+ # name as "+statement_timeout" and reject the connection.
116
+ new_query = urlencode(query, doseq=True, quote_via=quote)
92
117
  parsed = parsed._replace(query=new_query)
93
118
  dsn = urlunparse(parsed)
94
119
 
polydb/retry.py CHANGED
@@ -3,6 +3,7 @@
3
3
  Retry logic with exponential backoff and metrics hooks
4
4
  """
5
5
 
6
+ import os
6
7
  import time
7
8
  import logging
8
9
  from functools import wraps
@@ -74,7 +75,15 @@ def retry(
74
75
  @wraps(func)
75
76
  def wrapper(*args, **kwargs):
76
77
  attempt = 0
77
- current_delay = delay
78
+ # POLYDB_RETRY_DELAY_SECONDS / POLYDB_RETRY_BACKOFF override every
79
+ # call site's hardcoded delay/backoff without touching them
80
+ # individually -- every adapter passes delay=1.0 explicitly, so a
81
+ # transient failure against a high-latency remote DB (e.g. a local
82
+ # dev box talking to a managed Postgres in a different region)
83
+ # costs a full 1s+2s of sleep on top of the already-elevated
84
+ # network round trip, per retry. Unset, behavior is unchanged.
85
+ current_delay = float(os.getenv("POLYDB_RETRY_DELAY_SECONDS", delay))
86
+ backoff_rate = float(os.getenv("POLYDB_RETRY_BACKOFF", backoff))
78
87
 
79
88
  logger = logging.getLogger(__name__)
80
89
 
@@ -110,7 +119,7 @@ def retry(
110
119
  f"Retrying in {current_delay}s..."
111
120
  )
112
121
  time.sleep(current_delay)
113
- current_delay *= backoff
122
+ current_delay *= backoff_rate
114
123
  raise RuntimeError(
115
124
  f"{func.__name__} exhausted {max_attempts} attempts without returning"
116
125
  )