dycw-utilities 0.149.9__py3-none-any.whl → 0.149.10__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.
- {dycw_utilities-0.149.9.dist-info → dycw_utilities-0.149.10.dist-info}/METADATA +1 -1
- {dycw_utilities-0.149.9.dist-info → dycw_utilities-0.149.10.dist-info}/RECORD +8 -8
- utilities/__init__.py +1 -1
- utilities/asyncio.py +35 -0
- utilities/shelve.py +4 -1
- {dycw_utilities-0.149.9.dist-info → dycw_utilities-0.149.10.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.149.9.dist-info → dycw_utilities-0.149.10.dist-info}/entry_points.txt +0 -0
- {dycw_utilities-0.149.9.dist-info → dycw_utilities-0.149.10.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=loKT95lEsEfTUcmwQY8dkR_TL2ce2JNBkEhRMbcj5Ag,61
|
2
2
|
utilities/altair.py,sha256=92E2lCdyHY4Zb-vCw6rEJIsWdKipuu-Tu2ab1ufUfAk,9079
|
3
|
-
utilities/asyncio.py,sha256=
|
3
|
+
utilities/asyncio.py,sha256=2m2a2C-Qgc6OHTTHL332-t66A7xDITt_SORT7a1DJWo,16792
|
4
4
|
utilities/atomicwrites.py,sha256=xcOWenTBRS0oat3kg7Sqe51AohNThMQ2ixPL7QCG8hw,5795
|
5
5
|
utilities/atools.py,sha256=9im2g8OCf-Iynqa8bAv8N0Ycj9QvrJmGO7yLCZEdgII,986
|
6
6
|
utilities/cachetools.py,sha256=v1-9sXHLdOLiwmkq6NB0OUbxeKBuVVN6wmAWefWoaHI,2744
|
@@ -63,7 +63,7 @@ utilities/redis.py,sha256=MNxDTbTQTkUOtIikJY9UbfozTC3zuJpAUBsw02LLXTA,28377
|
|
63
63
|
utilities/reprlib.py,sha256=ssYTcBW-TeRh3fhCJv57sopTZHF5FrPyyUg9yp5XBlo,3953
|
64
64
|
utilities/scipy.py,sha256=wZJM7fEgBAkLSYYvSmsg5ac-QuwAI0BGqHVetw1_Hb0,947
|
65
65
|
utilities/sentinel.py,sha256=3jIwgpMekWgDAxPDA_hXMP2St43cPhciKN3LWiZ7kv0,1248
|
66
|
-
utilities/shelve.py,sha256=
|
66
|
+
utilities/shelve.py,sha256=4OzjQI6kGuUbJciqf535rwnao-_IBv66gsT6tRGiUt0,759
|
67
67
|
utilities/slack_sdk.py,sha256=ppFBvKgfg5IRWiIoKPtpTyzBtBF4XmwEvU3I5wLJikM,2140
|
68
68
|
utilities/socket.py,sha256=K77vfREvzoVTrpYKo6MZakol0EYu2q1sWJnnZqL0So0,118
|
69
69
|
utilities/sqlalchemy.py,sha256=q2aYUDAC3SE88Lt6XaKa3CLzT_ePaWvQu_OuRk19x9g,35520
|
@@ -89,8 +89,8 @@ utilities/zoneinfo.py,sha256=oEH-nL3t4h9uawyZqWDtNtDAl6M-CLpLYGI_nI6DulM,1971
|
|
89
89
|
utilities/pytest_plugins/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
90
90
|
utilities/pytest_plugins/pytest_randomly.py,sha256=NXzCcGKbpgYouz5yehKb4jmxmi2SexKKpgF4M65bi10,414
|
91
91
|
utilities/pytest_plugins/pytest_regressions.py,sha256=Iwhfv_OJH7UCPZCfoh7ugZ2Xjqjil-BBBsOb8sDwiGI,1471
|
92
|
-
dycw_utilities-0.149.
|
93
|
-
dycw_utilities-0.149.
|
94
|
-
dycw_utilities-0.149.
|
95
|
-
dycw_utilities-0.149.
|
96
|
-
dycw_utilities-0.149.
|
92
|
+
dycw_utilities-0.149.10.dist-info/METADATA,sha256=EbgjAbqUqMjs6OSUe3OOxvI9tsyWzQTysNvXw84cbYQ,1698
|
93
|
+
dycw_utilities-0.149.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
94
|
+
dycw_utilities-0.149.10.dist-info/entry_points.txt,sha256=BOD_SoDxwsfJYOLxhrSXhHP_T7iw-HXI9f2WVkzYxvQ,135
|
95
|
+
dycw_utilities-0.149.10.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.149.10.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/asyncio.py
CHANGED
@@ -22,6 +22,7 @@ from contextlib import (
|
|
22
22
|
)
|
23
23
|
from dataclasses import dataclass
|
24
24
|
from io import StringIO
|
25
|
+
from pathlib import Path
|
25
26
|
from subprocess import PIPE
|
26
27
|
from sys import stderr, stdout
|
27
28
|
from typing import (
|
@@ -40,6 +41,7 @@ from utilities.functions import ensure_int, ensure_not_none, to_bool
|
|
40
41
|
from utilities.logging import get_logger
|
41
42
|
from utilities.random import SYSTEM_RANDOM
|
42
43
|
from utilities.sentinel import Sentinel, sentinel
|
44
|
+
from utilities.shelve import yield_shelf
|
43
45
|
from utilities.warnings import suppress_warnings
|
44
46
|
from utilities.whenever import get_now, round_date_or_date_time, to_nanoseconds
|
45
47
|
|
@@ -58,10 +60,12 @@ if TYPE_CHECKING:
|
|
58
60
|
)
|
59
61
|
from contextvars import Context
|
60
62
|
from random import Random
|
63
|
+
from shelve import Shelf
|
61
64
|
from types import TracebackType
|
62
65
|
|
63
66
|
from whenever import ZonedDateTime
|
64
67
|
|
68
|
+
from utilities.shelve import _Flag
|
65
69
|
from utilities.types import (
|
66
70
|
Coro,
|
67
71
|
Delta,
|
@@ -69,6 +73,7 @@ if TYPE_CHECKING:
|
|
69
73
|
LoggerOrName,
|
70
74
|
MaybeCallableBool,
|
71
75
|
MaybeType,
|
76
|
+
PathLike,
|
72
77
|
SupportsKeysAndGetItem,
|
73
78
|
)
|
74
79
|
|
@@ -547,6 +552,35 @@ async def timeout_td(
|
|
547
552
|
raise error from None
|
548
553
|
|
549
554
|
|
555
|
+
##
|
556
|
+
|
557
|
+
|
558
|
+
_LOCKS: AsyncDict[Path, Lock] = AsyncDict()
|
559
|
+
|
560
|
+
|
561
|
+
@asynccontextmanager
|
562
|
+
async def yield_locked_shelf(
|
563
|
+
path: PathLike,
|
564
|
+
/,
|
565
|
+
*,
|
566
|
+
flag: _Flag = "c",
|
567
|
+
protocol: int | None = None,
|
568
|
+
writeback: bool = False,
|
569
|
+
) -> AsyncIterator[Shelf[Any]]:
|
570
|
+
"""Yield a shelf, behind a lock."""
|
571
|
+
path = Path(path)
|
572
|
+
try:
|
573
|
+
lock = _LOCKS[path]
|
574
|
+
except KeyError:
|
575
|
+
lock = Lock()
|
576
|
+
await _LOCKS.set(path, lock)
|
577
|
+
async with lock:
|
578
|
+
with yield_shelf(
|
579
|
+
path, flag=flag, protocol=protocol, writeback=writeback
|
580
|
+
) as shelf:
|
581
|
+
yield shelf
|
582
|
+
|
583
|
+
|
550
584
|
__all__ = [
|
551
585
|
"AsyncDict",
|
552
586
|
"EnhancedTaskGroup",
|
@@ -563,4 +597,5 @@ __all__ = [
|
|
563
597
|
"sleep_until",
|
564
598
|
"stream_command",
|
565
599
|
"timeout_td",
|
600
|
+
"yield_locked_shelf",
|
566
601
|
]
|
utilities/shelve.py
CHANGED
@@ -12,12 +12,15 @@ if TYPE_CHECKING:
|
|
12
12
|
from utilities.types import PathLike
|
13
13
|
|
14
14
|
|
15
|
+
type _Flag = Literal["r", "w", "c", "n"]
|
16
|
+
|
17
|
+
|
15
18
|
@contextmanager
|
16
19
|
def yield_shelf(
|
17
20
|
path: PathLike,
|
18
21
|
/,
|
19
22
|
*,
|
20
|
-
flag:
|
23
|
+
flag: _Flag = "c",
|
21
24
|
protocol: int | None = None,
|
22
25
|
writeback: bool = False,
|
23
26
|
) -> Iterator[Shelf[Any]]:
|
File without changes
|
File without changes
|
File without changes
|