kisa-utils 0.42.5__py3-none-any.whl → 0.42.7__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.
- kisa_utils/dates.py +6 -3
- kisa_utils/db.py +16 -2
- {kisa_utils-0.42.5.dist-info → kisa_utils-0.42.7.dist-info}/METADATA +1 -1
- {kisa_utils-0.42.5.dist-info → kisa_utils-0.42.7.dist-info}/RECORD +6 -6
- {kisa_utils-0.42.5.dist-info → kisa_utils-0.42.7.dist-info}/WHEEL +0 -0
- {kisa_utils-0.42.5.dist-info → kisa_utils-0.42.7.dist-info}/top_level.txt +0 -0
kisa_utils/dates.py
CHANGED
|
@@ -396,14 +396,17 @@ def endOfCurrentMonth() -> str:
|
|
|
396
396
|
year, month, day = dateToday.split('-')
|
|
397
397
|
return endOfMonth(year, month)
|
|
398
398
|
|
|
399
|
-
def dateIsValid(date:str) -> bool:
|
|
399
|
+
def dateIsValid(date:str, dateFormat:str='YYYY-MM-DD') -> bool:
|
|
400
400
|
'''
|
|
401
|
-
check if a date is valid in the format
|
|
401
|
+
check if a date is valid in the provided format
|
|
402
402
|
Args:
|
|
403
403
|
date(str): the date to check
|
|
404
|
+
dateFormat(str): the date format for which to check the date. common formats are;
|
|
405
|
+
- 'YYYY-MM-DD'
|
|
406
|
+
- 'YYYY-MM-DD HH:MM:SS'
|
|
404
407
|
'''
|
|
405
408
|
try:
|
|
406
|
-
standardizedDate(date,
|
|
409
|
+
standardizedDate(date, dateFormat)
|
|
407
410
|
except:
|
|
408
411
|
return False
|
|
409
412
|
|
kisa_utils/db.py
CHANGED
|
@@ -7,6 +7,7 @@ import inspect
|
|
|
7
7
|
import traceback
|
|
8
8
|
import re
|
|
9
9
|
from threading import get_native_id as getCurrentThreadId, Lock
|
|
10
|
+
import random, time
|
|
10
11
|
|
|
11
12
|
from . import storage
|
|
12
13
|
from . import codes
|
|
@@ -142,6 +143,7 @@ class Api:
|
|
|
142
143
|
accessFromMultipleThreads:bool = False,
|
|
143
144
|
useWALMode:bool = True,
|
|
144
145
|
returnKISAResponse:bool|None = None,
|
|
146
|
+
connectionTimeout:float = 30.0
|
|
145
147
|
):
|
|
146
148
|
'''
|
|
147
149
|
attempt to open an sqlite3 database connection object/instance
|
|
@@ -238,9 +240,21 @@ class Api:
|
|
|
238
240
|
|
|
239
241
|
self._readonly = True if readonly else False
|
|
240
242
|
|
|
241
|
-
self.db:sqlite3.Connection
|
|
243
|
+
self.db:sqlite3.Connection
|
|
244
|
+
|
|
245
|
+
max_retries = 4
|
|
246
|
+
for attempt in range(max_retries):
|
|
247
|
+
try:
|
|
248
|
+
self.db = sqlite3.connect(path, check_same_thread = not accessFromMultipleThreads, timeout=connectionTimeout)
|
|
249
|
+
break
|
|
250
|
+
except sqlite3.OperationalError as e:
|
|
251
|
+
if attempt == max_retries - 1:
|
|
252
|
+
raise # Re-raise on final attempt
|
|
253
|
+
|
|
254
|
+
wait_time = (2 ** attempt) + random.uniform(0, 1) # Exponential backoff with jitter
|
|
255
|
+
print(f"Database connection attempt {attempt + 1} failed: {e}. Retrying in {wait_time:.2f}s...")
|
|
256
|
+
time.sleep(wait_time)
|
|
242
257
|
|
|
243
|
-
self.db = sqlite3.connect(path, check_same_thread = not accessFromMultipleThreads)
|
|
244
258
|
if useWALMode:
|
|
245
259
|
self.db.executescript(f'''
|
|
246
260
|
/* set journal mode to WAL and `synchronous` to best value, which works best for WAL mode*/
|
|
@@ -3,8 +3,8 @@ kisa_utils/cache.py,sha256=WOL3e0wvoyESXTtlbVnUg9TYUoLzg64sLP9J4b4ti9k,7377
|
|
|
3
3
|
kisa_utils/codes.py,sha256=PV_S53Skggf4XetOdYoIKtEmM8cpN5wZwUlxje70WZY,904
|
|
4
4
|
kisa_utils/config.py,sha256=NfluzGKTh66qfNtC-Ae0zNb1XzMTgU2Me9Vi82R9c1E,2285
|
|
5
5
|
kisa_utils/dataStructures.py,sha256=ZgLpttJ66jfpU1NWzLDD1Czqxzj6sWereffgTQWhlV8,2679
|
|
6
|
-
kisa_utils/dates.py,sha256=
|
|
7
|
-
kisa_utils/db.py,sha256
|
|
6
|
+
kisa_utils/dates.py,sha256=JN0vm-7_fOdpzLtondVmpjpWoePPJn4aGK0NkBuyF8I,14142
|
|
7
|
+
kisa_utils/db.py,sha256=-0Q7iw9VEtf4oyOIj_IhJqmzeh0CZVp3vEcwIQn4Zls,54939
|
|
8
8
|
kisa_utils/encryption.py,sha256=nFzNpzWV_D9uSEq4FsgCnlS7FQtqWP9fvM_81rsfcLo,4218
|
|
9
9
|
kisa_utils/figures.py,sha256=pYIpQzu1OXRSsY1d98GhgPifnIRmgl-r7S32ai-Ms0c,3731
|
|
10
10
|
kisa_utils/functionUtils.py,sha256=PlXjnmU1uJWNdISlJJ3SCgavTsgNBoebaa9dtWSFhRA,6553
|
|
@@ -27,7 +27,7 @@ kisa_utils/servers/flask.py,sha256=XZYY1pWnP1mSvaS5Uv8G3EFJV5BJBQtU2gDbO8suvLc,4
|
|
|
27
27
|
kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
|
|
28
28
|
kisa_utils/structures/utils.py,sha256=665rXIapGwFqejizeJwy3DryeskCQOdgP25BCdLkGvk,2898
|
|
29
29
|
kisa_utils/structures/validator.py,sha256=JhD9jcfbjTwBr_7OfuNaJd_cYr7wR2emFhsCEo5MCHQ,4323
|
|
30
|
-
kisa_utils-0.42.
|
|
31
|
-
kisa_utils-0.42.
|
|
32
|
-
kisa_utils-0.42.
|
|
33
|
-
kisa_utils-0.42.
|
|
30
|
+
kisa_utils-0.42.7.dist-info/METADATA,sha256=NS58kF6uyqn0xEcjltRwD6IAEQArJqSB4N0_a_j6Ctg,477
|
|
31
|
+
kisa_utils-0.42.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
32
|
+
kisa_utils-0.42.7.dist-info/top_level.txt,sha256=GFOLXZYqpBG9xtscGa2uGJAEiZ5NwsqHBH9NylnB29M,11
|
|
33
|
+
kisa_utils-0.42.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|