esuls 0.1.9__tar.gz → 0.1.11__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.
- {esuls-0.1.9/src/esuls.egg-info → esuls-0.1.11}/PKG-INFO +1 -1
- {esuls-0.1.9 → esuls-0.1.11}/pyproject.toml +1 -1
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls/db_cli.py +15 -6
- esuls-0.1.11/src/esuls/utils.py +23 -0
- {esuls-0.1.9 → esuls-0.1.11/src/esuls.egg-info}/PKG-INFO +1 -1
- esuls-0.1.9/src/esuls/utils.py +0 -28
- {esuls-0.1.9 → esuls-0.1.11}/LICENSE +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/README.md +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/setup.cfg +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls/__init__.py +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls/download_icon.py +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls/request_cli.py +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls.egg-info/SOURCES.txt +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls.egg-info/dependency_links.txt +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls.egg-info/requires.txt +0 -0
- {esuls-0.1.9 → esuls-0.1.11}/src/esuls.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "esuls"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.11"
|
|
8
8
|
description = "Utility library for async database operations, HTTP requests, and parallel execution"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -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
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
General utilities - no external dependencies required
|
|
3
|
+
"""
|
|
4
|
+
import asyncio
|
|
5
|
+
from typing import Awaitable, Callable, List, TypeVar
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async def run_parallel(
|
|
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
|
+
|
esuls-0.1.9/src/esuls/utils.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
General utilities - no external dependencies required
|
|
3
|
-
"""
|
|
4
|
-
import asyncio
|
|
5
|
-
from typing import Awaitable, Callable, List, TypeVar
|
|
6
|
-
|
|
7
|
-
T = TypeVar("T")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
async def run_parallel(
|
|
11
|
-
*coroutines: Awaitable[T],
|
|
12
|
-
limit: int = 20
|
|
13
|
-
) -> List[T]:
|
|
14
|
-
"""Run parallel coroutines with semaphore limit"""
|
|
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
|
-
tasks = [asyncio.create_task(limited_coroutine(coro)) for coro in coroutines]
|
|
23
|
-
|
|
24
|
-
results = []
|
|
25
|
-
for fut in asyncio.as_completed(tasks):
|
|
26
|
-
results.append(await fut)
|
|
27
|
-
|
|
28
|
-
return results
|
|
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
|
|
File without changes
|