esuls 0.1.9__py3-none-any.whl → 0.1.11__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 +15 -6
- esuls/utils.py +13 -18
- {esuls-0.1.9.dist-info → esuls-0.1.11.dist-info}/METADATA +1 -1
- esuls-0.1.11.dist-info/RECORD +10 -0
- esuls-0.1.9.dist-info/RECORD +0 -10
- {esuls-0.1.9.dist-info → esuls-0.1.11.dist-info}/WHEEL +0 -0
- {esuls-0.1.9.dist-info → esuls-0.1.11.dist-info}/licenses/LICENSE +0 -0
- {esuls-0.1.9.dist-info → esuls-0.1.11.dist-info}/top_level.txt +0 -0
esuls/db_cli.py
CHANGED
|
@@ -23,25 +23,34 @@ class BaseModel:
|
|
|
23
23
|
|
|
24
24
|
class AsyncDB(Generic[SchemaType]):
|
|
25
25
|
"""High-performance async SQLite with dataclass schema and reliable connection handling."""
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
OPERATOR_MAP = {
|
|
28
|
-
'gt': '>', 'lt': '<', 'gte': '>=', 'lte': '<=',
|
|
28
|
+
'gt': '>', 'lt': '<', 'gte': '>=', 'lte': '<=',
|
|
29
29
|
'neq': '!=', 'like': 'LIKE', 'in': 'IN', 'eq': '='
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
# Shared write locks per database file (class-level)
|
|
33
|
+
_db_locks: dict[str, asyncio.Lock] = {}
|
|
34
|
+
|
|
32
35
|
def __init__(self, db_path: Union[str, Path], table_name: str, schema_class: Type[SchemaType]):
|
|
33
36
|
"""Initialize AsyncDB with a path and schema dataclass."""
|
|
34
37
|
if not is_dataclass(schema_class):
|
|
35
38
|
raise TypeError(f"Schema must be a dataclass, got {schema_class}")
|
|
36
|
-
|
|
39
|
+
|
|
37
40
|
self.db_path = Path(db_path).resolve()
|
|
38
41
|
self.schema_class = schema_class
|
|
39
42
|
self.table_name = table_name
|
|
40
43
|
self.db_path.parent.mkdir(parents=True, exist_ok=True)
|
|
41
|
-
|
|
44
|
+
|
|
42
45
|
# Make schema initialization unique per instance
|
|
43
46
|
self._db_key = f"{str(self.db_path)}:{self.table_name}:{self.schema_class.__name__}"
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
# Use shared lock per database file (not per instance)
|
|
49
|
+
db_path_str = str(self.db_path)
|
|
50
|
+
if db_path_str not in AsyncDB._db_locks:
|
|
51
|
+
AsyncDB._db_locks[db_path_str] = asyncio.Lock()
|
|
52
|
+
self._write_lock = AsyncDB._db_locks[db_path_str]
|
|
53
|
+
|
|
45
54
|
self._type_hints = get_type_hints(schema_class)
|
|
46
55
|
|
|
47
56
|
# Use a class-level set to track initialized schemas
|
esuls/utils.py
CHANGED
|
@@ -8,21 +8,16 @@ T = TypeVar("T")
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
async def run_parallel(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
) -> List[T]:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
results = []
|
|
25
|
-
for fut in asyncio.as_completed(tasks):
|
|
26
|
-
results.append(await fut)
|
|
27
|
-
|
|
28
|
-
return results
|
|
11
|
+
*coroutines: Awaitable[T],
|
|
12
|
+
limit: int = 20
|
|
13
|
+
) -> List[T]:
|
|
14
|
+
"""Run parallel coroutines with semaphore limit, preserving order"""
|
|
15
|
+
|
|
16
|
+
semaphore = asyncio.Semaphore(limit)
|
|
17
|
+
|
|
18
|
+
async def limited_coroutine(coro: Awaitable[T]) -> T:
|
|
19
|
+
async with semaphore:
|
|
20
|
+
return await coro
|
|
21
|
+
|
|
22
|
+
return await asyncio.gather(*[limited_coroutine(coro) for coro in coroutines])
|
|
23
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
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=Lfxl0fwSq0npQb_qzWj7tTeqXR6tuZKpOYkjtpWjxHQ,15084
|
|
5
|
+
esuls/utils.py,sha256=AAh9y8dSB1vGO8e7A10dpsYMPI5-e9gw-GPInYBoOvg,577
|
|
6
|
+
esuls-0.1.11.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
|
|
7
|
+
esuls-0.1.11.dist-info/METADATA,sha256=IwgBg_skCm0C-uGFhm-7xqayh74KaE0E-_93kYT5gaE,6995
|
|
8
|
+
esuls-0.1.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
esuls-0.1.11.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
|
|
10
|
+
esuls-0.1.11.dist-info/RECORD,,
|
esuls-0.1.9.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
esuls/__init__.py,sha256=dtZtmjZZ8jNspOd17BWsE9D9ofeg3vZF0vIpSgKaZqk,529
|
|
2
|
-
esuls/db_cli.py,sha256=F1XwkuzCc69ldnDv0-X4kl4VZ9zI6oJnqmQAOe2d8jE,17931
|
|
3
|
-
esuls/download_icon.py,sha256=w-bWbyPSbWvonzq43aDDtdxIvdKSa7OSyZ7LaN0uudg,3623
|
|
4
|
-
esuls/request_cli.py,sha256=Lfxl0fwSq0npQb_qzWj7tTeqXR6tuZKpOYkjtpWjxHQ,15084
|
|
5
|
-
esuls/utils.py,sha256=PjdxbcolJEiab9d5r6f8cLz2bE-S-vuCImcYUoMyTAQ,675
|
|
6
|
-
esuls-0.1.9.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
|
|
7
|
-
esuls-0.1.9.dist-info/METADATA,sha256=GV2GIJSCNBfBFGUt189fHJAWNCCOFMdJziWfZZm_ScA,6994
|
|
8
|
-
esuls-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
esuls-0.1.9.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
|
|
10
|
-
esuls-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|