esuls 0.1.10__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 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
- self._write_lock = asyncio.Lock()
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: esuls
3
- Version: 0.1.10
3
+ Version: 0.1.11
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=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,,
@@ -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=AAh9y8dSB1vGO8e7A10dpsYMPI5-e9gw-GPInYBoOvg,577
6
- esuls-0.1.10.dist-info/licenses/LICENSE,sha256=AY0N01ARt0kbKB7CkByYLqqNQU-yalb-rpv-eXITEWA,1066
7
- esuls-0.1.10.dist-info/METADATA,sha256=PCP8V4k_ZZLX4R2KtYFgbAxQsnC4v8wbfsJEDHtMyq0,6995
8
- esuls-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- esuls-0.1.10.dist-info/top_level.txt,sha256=WWBDHRhQ0DQLBZKD7Un8uFN93GvVQnP4WvJKkvbACVA,6
10
- esuls-0.1.10.dist-info/RECORD,,
File without changes