esuls 0.1.12__py3-none-any.whl → 0.1.13__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.
esuls/db_cli.py CHANGED
@@ -57,20 +57,33 @@ class AsyncDB(Generic[SchemaType]):
57
57
  if not hasattr(AsyncDB, '_initialized_schemas'):
58
58
  AsyncDB._initialized_schemas = set()
59
59
 
60
- async def _get_connection(self) -> aiosqlite.Connection:
61
- """Create a new optimized connection."""
62
- db = await aiosqlite.connect(self.db_path)
63
- # Fast WAL mode with minimal sync
64
- await db.execute("PRAGMA journal_mode=WAL")
65
- await db.execute("PRAGMA synchronous=NORMAL")
66
- await db.execute("PRAGMA cache_size=10000")
67
-
68
- # Initialize schema if needed (check per unique schema)
69
- if self._db_key not in AsyncDB._initialized_schemas:
70
- await self._init_schema(db)
71
- AsyncDB._initialized_schemas.add(self._db_key)
72
-
73
- return db
60
+ async def _get_connection(self, max_retries: int = 5) -> aiosqlite.Connection:
61
+ """Create a new optimized connection with retry logic for concurrent access."""
62
+ last_error = None
63
+ for attempt in range(max_retries):
64
+ try:
65
+ db = await aiosqlite.connect(self.db_path, timeout=30.0)
66
+ # Fast WAL mode with minimal sync
67
+ await db.execute("PRAGMA journal_mode=WAL")
68
+ await db.execute("PRAGMA synchronous=NORMAL")
69
+ await db.execute("PRAGMA cache_size=10000")
70
+ await db.execute("PRAGMA busy_timeout=30000") # 30s busy timeout
71
+
72
+ # Initialize schema if needed (check per unique schema)
73
+ if self._db_key not in AsyncDB._initialized_schemas:
74
+ await self._init_schema(db)
75
+ AsyncDB._initialized_schemas.add(self._db_key)
76
+
77
+ return db
78
+ except Exception as e:
79
+ last_error = e
80
+ if attempt < max_retries - 1:
81
+ # Exponential backoff: 0.1s, 0.2s, 0.4s, 0.8s, 1.6s
82
+ wait_time = 0.1 * (2 ** attempt)
83
+ await asyncio.sleep(wait_time)
84
+ continue
85
+ raise
86
+ raise last_error
74
87
 
75
88
  async def _init_schema(self, db: aiosqlite.Connection) -> None:
76
89
  """Generate schema from dataclass structure with support for field additions."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esuls
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: Utility library for async database operations, HTTP requests, and parallel execution
5
5
  Author-email: IperGiove <ipergiove@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,10 @@
1
+ esuls/__init__.py,sha256=dtZtmjZZ8jNspOd17BWsE9D9ofeg3vZF0vIpSgKaZqk,529
2
+ esuls/db_cli.py,sha256=_5qEsfHr_cSDGitAe33hTNjVkfbHQxnPhEl1WDsuBIc,18901
3
+ esuls/download_icon.py,sha256=w-bWbyPSbWvonzq43aDDtdxIvdKSa7OSyZ7LaN0uudg,3623
4
+ esuls/request_cli.py,sha256=pILF8J9IILpTmWacm1vCtvDaef-kOXjkWAbcE2S9_cA,17962
5
+ esuls/utils.py,sha256=AAh9y8dSB1vGO8e7A10dpsYMPI5-e9gw-GPInYBoOvg,577
6
+ esuls-0.1.13.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
7
+ esuls-0.1.13.dist-info/METADATA,sha256=abi71dKeWsGmI0wB01XQUTtv9xKkN1bztcCze330m1Q,7002
8
+ esuls-0.1.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ esuls-0.1.13.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
10
+ esuls-0.1.13.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- esuls/__init__.py,sha256=dtZtmjZZ8jNspOd17BWsE9D9ofeg3vZF0vIpSgKaZqk,529
2
- esuls/db_cli.py,sha256=fGCKJDvPL1VeqLj8My-It1U0WIS365M6rakNMdzXbuk,18234
3
- esuls/download_icon.py,sha256=w-bWbyPSbWvonzq43aDDtdxIvdKSa7OSyZ7LaN0uudg,3623
4
- esuls/request_cli.py,sha256=pILF8J9IILpTmWacm1vCtvDaef-kOXjkWAbcE2S9_cA,17962
5
- esuls/utils.py,sha256=AAh9y8dSB1vGO8e7A10dpsYMPI5-e9gw-GPInYBoOvg,577
6
- esuls-0.1.12.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
7
- esuls-0.1.12.dist-info/METADATA,sha256=wAUYuyCsfT5mFby1IYmbrWmT97YxnlBzrm5zshi4GXg,7002
8
- esuls-0.1.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- esuls-0.1.12.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
10
- esuls-0.1.12.dist-info/RECORD,,
File without changes