zstdlib 0.10.14__tar.gz → 0.10.15__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.
- {zstdlib-0.10.14 → zstdlib-0.10.15}/PKG-INFO +1 -1
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_ip_lock.py +13 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/__init__.py +1 -1
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/hybridmethod.py +1 -1
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/io.py +2 -2
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/ip_lock.py +12 -15
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/prompt.py +6 -6
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib.egg-info/PKG-INFO +1 -1
- {zstdlib-0.10.14 → zstdlib-0.10.15}/LICENSE +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/README.md +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/pyproject.toml +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/setup.cfg +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/__init__.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/log/__init__.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/log/base.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/log/test_cute.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/log/test_trace.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_ansi.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_enum.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_frozen.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_hybridmethod.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_io.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_keyed_instance.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_lazy.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_not_set.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_prompt.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_singleton.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/tests/test_util.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/ansi.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/enum.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/exc/__init__.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/exc/capture.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/exc/pop_frames.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/exc/raise_.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/frozen.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/keyed_instance.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/lazy.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/log/__init__.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/log/cute.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/log/trace.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/macos.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/not_set.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/py.typed +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/signal_cm.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/singleton.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib/util.py +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib.egg-info/SOURCES.txt +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib.egg-info/dependency_links.txt +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib.egg-info/requires.txt +0 -0
- {zstdlib-0.10.14 → zstdlib-0.10.15}/zstdlib.egg-info/top_level.txt +0 -0
|
@@ -185,26 +185,34 @@ class TestGlobalProcessLock(unittest.TestCase):
|
|
|
185
185
|
def test_sole_owner(self) -> None:
|
|
186
186
|
with mk_gipl() as lock:
|
|
187
187
|
self.assertFalse(lock.acquired)
|
|
188
|
+
self.assertEqual(lock.hold_count, 0)
|
|
188
189
|
# Can acquire existing file
|
|
189
190
|
self.assertTrue(lock.acquire(timeout_per=0))
|
|
190
191
|
self.assertTrue(lock.acquired)
|
|
192
|
+
self.assertEqual(lock.hold_count, 1)
|
|
191
193
|
# Re-acquisition, count == 2
|
|
192
194
|
self.assertTrue(lock.acquire(timeout_per=0))
|
|
193
195
|
self.assertTrue(lock.acquired)
|
|
196
|
+
self.assertEqual(lock.hold_count, 2)
|
|
194
197
|
# Release 1/2
|
|
195
198
|
lock.release()
|
|
196
199
|
self.assertTrue(lock.acquired)
|
|
200
|
+
self.assertEqual(lock.hold_count, 1)
|
|
197
201
|
# Release 2/2
|
|
198
202
|
lock.release()
|
|
199
203
|
self.assertFalse(lock.acquired)
|
|
204
|
+
self.assertEqual(lock.hold_count, 0)
|
|
200
205
|
# Release 3/2
|
|
201
206
|
with self.assertRaises(NotAcquiredError):
|
|
202
207
|
lock.release()
|
|
203
208
|
self.assertFalse(lock.acquired)
|
|
209
|
+
self.assertEqual(lock.hold_count, 0)
|
|
204
210
|
# CM exit, lock file removed by NTF
|
|
205
211
|
# Fresh acquire on non-existing file
|
|
206
212
|
lock.acquire(timeout_per=0)
|
|
213
|
+
self.assertTrue(lock.acquired)
|
|
207
214
|
lock.release()
|
|
215
|
+
self.assertFalse(lock.acquired)
|
|
208
216
|
|
|
209
217
|
def test_global(self) -> None:
|
|
210
218
|
with mk_gipl() as lock:
|
|
@@ -259,6 +267,7 @@ class TestIPLocks(unittest.TestCase):
|
|
|
259
267
|
# pylint: disable=protected-access
|
|
260
268
|
self.assertIs(lock._gipl, lock2._gipl)
|
|
261
269
|
self.assertFalse(lock._gipl.acquired)
|
|
270
|
+
self.assertEqual(lock._gipl.hold_count, 0)
|
|
262
271
|
with enter(lock):
|
|
263
272
|
|
|
264
273
|
def chk() -> None:
|
|
@@ -317,13 +326,17 @@ class TestIPLocks(unittest.TestCase):
|
|
|
317
326
|
# pylint: enable=protected-access
|
|
318
327
|
with mk_lock(IPLock) as lock, enter(lock):
|
|
319
328
|
self.assertTrue(lock.acquired)
|
|
329
|
+
self.assertEqual(lock.hold_count, 1)
|
|
320
330
|
self.assertFalse(lock.acquire(timeout_per=2))
|
|
321
331
|
self.assertTrue(lock.acquired)
|
|
332
|
+
self.assertEqual(lock.hold_count, 1)
|
|
322
333
|
self.assertFalse(lock.acquired)
|
|
323
334
|
del lock
|
|
324
335
|
with mk_lock(RIPLock) as rlock, enter(rlock), enter(rlock):
|
|
325
336
|
self.assertTrue(rlock.acquired)
|
|
337
|
+
self.assertEqual(rlock.hold_count, 2)
|
|
326
338
|
self.assertFalse(rlock.acquired)
|
|
339
|
+
self.assertEqual(rlock.hold_count, 0)
|
|
327
340
|
del rlock
|
|
328
341
|
|
|
329
342
|
with mk_lock(IPLock) as lock, self.assertRaises(LockPathInUseError):
|
|
@@ -39,7 +39,7 @@ class hybridmethod[T, R, **P]: # Name aligns with @staticmethod and such
|
|
|
39
39
|
self._name = name
|
|
40
40
|
|
|
41
41
|
@overload
|
|
42
|
-
def __get__(self, instance: T, owner: type[T] | None =
|
|
42
|
+
def __get__(self, instance: T, owner: type[T] | None = ..., /) -> Callable[P, R]: ...
|
|
43
43
|
|
|
44
44
|
@overload
|
|
45
45
|
def __get__(self, instance: None, owner: type[T], /) -> Callable[P, R]: ...
|
|
@@ -202,11 +202,11 @@ class BinaryIO(_IOWrapperBase[bytes]):
|
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
@overload
|
|
205
|
-
def io(raw: IO[str], binary: bool | None =
|
|
205
|
+
def io(raw: IO[str], binary: bool | None = ...) -> TextIO: ...
|
|
206
206
|
|
|
207
207
|
|
|
208
208
|
@overload
|
|
209
|
-
def io(raw: IO[bytes], binary: bool | None =
|
|
209
|
+
def io(raw: IO[bytes], binary: bool | None = ...) -> BinaryIO: ...
|
|
210
210
|
|
|
211
211
|
|
|
212
212
|
def io[T: (str, bytes)](raw: IO[T], binary: bool | None = None) -> TextIO | BinaryIO:
|
|
@@ -32,6 +32,8 @@ class LockHungError(RuntimeError):
|
|
|
32
32
|
class AbstractIPLock(ABC):
|
|
33
33
|
"""An abstract interprocess lock that uses a Path for IPC synchronization"""
|
|
34
34
|
|
|
35
|
+
_rc: int # Instance varaible for subclasses to define
|
|
36
|
+
|
|
35
37
|
# Abstract Methods
|
|
36
38
|
|
|
37
39
|
@property
|
|
@@ -40,9 +42,15 @@ class AbstractIPLock(ABC):
|
|
|
40
42
|
"""The path this lock is synchronized across processes with"""
|
|
41
43
|
|
|
42
44
|
@property
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
def acquired(self) -> int:
|
|
46
|
+
"""Return True if the lock has been acquired; an alias for bool(self.hold_count)"""
|
|
47
|
+
return bool(self.hold_count)
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def hold_count(self) -> int:
|
|
51
|
+
"""Return the lock hold count / how many times this lock must be released"""
|
|
52
|
+
assert self._rc >= 0
|
|
53
|
+
return self._rc
|
|
46
54
|
|
|
47
55
|
@abstractmethod
|
|
48
56
|
def _acquire(self, blocking: bool, timeout_per: float | None) -> bool:
|
|
@@ -148,12 +156,6 @@ class GlobalIPLock(KeyedInstance, AbstractIPLock):
|
|
|
148
156
|
"""The path the lock is synchronized on"""
|
|
149
157
|
return self._path
|
|
150
158
|
|
|
151
|
-
@property
|
|
152
|
-
@override
|
|
153
|
-
def acquired(self) -> bool:
|
|
154
|
-
"""Return true if acquired"""
|
|
155
|
-
return bool(self._rc)
|
|
156
|
-
|
|
157
159
|
@override
|
|
158
160
|
def _acquire(self, blocking: bool, timeout_per: float | None) -> bool:
|
|
159
161
|
ret: bool = True
|
|
@@ -204,6 +206,7 @@ class _IPLock(AbstractIPLock):
|
|
|
204
206
|
"""
|
|
205
207
|
Construct an inter process lock syncronized by gipl (or GlobalIPLock.new(gipl) if str | Path)
|
|
206
208
|
If a lock of a different reentrancy setting already exists for this gipl, raise LockPathInUseError
|
|
209
|
+
args / kwargs are exclusively for super.__init__
|
|
207
210
|
"""
|
|
208
211
|
super().__init__(*args, **kwargs) # For MRO superclasses
|
|
209
212
|
if isinstance(gipl, Path | str):
|
|
@@ -229,12 +232,6 @@ class _IPLock(AbstractIPLock):
|
|
|
229
232
|
"""The path the lock is synchronized on"""
|
|
230
233
|
return self._gipl.path
|
|
231
234
|
|
|
232
|
-
@property
|
|
233
|
-
@override
|
|
234
|
-
def acquired(self) -> bool:
|
|
235
|
-
"""Return true if locked"""
|
|
236
|
-
return bool(self._rc) # Might return False during .release() after rc -=1, before .release()
|
|
237
|
-
|
|
238
235
|
@override
|
|
239
236
|
def _acquire(self, blocking: bool, timeout_per: float | None) -> bool:
|
|
240
237
|
ret = False
|
|
@@ -10,9 +10,9 @@ def prompt_until(
|
|
|
10
10
|
msg: str,
|
|
11
11
|
until: str | Iterable[str],
|
|
12
12
|
*,
|
|
13
|
-
ignore_case: bool =
|
|
14
|
-
eof: Literal[False] =
|
|
15
|
-
ctrl_c: Literal[False] =
|
|
13
|
+
ignore_case: bool = ...,
|
|
14
|
+
eof: Literal[False] = ...,
|
|
15
|
+
ctrl_c: Literal[False] = ...,
|
|
16
16
|
) -> str: ...
|
|
17
17
|
|
|
18
18
|
|
|
@@ -21,9 +21,9 @@ def prompt_until(
|
|
|
21
21
|
msg: str,
|
|
22
22
|
until: str | Iterable[str],
|
|
23
23
|
*,
|
|
24
|
-
ignore_case: bool =
|
|
25
|
-
eof: bool =
|
|
26
|
-
ctrl_c: bool =
|
|
24
|
+
ignore_case: bool = ...,
|
|
25
|
+
eof: bool = ...,
|
|
26
|
+
ctrl_c: bool = ...,
|
|
27
27
|
) -> str | None: ...
|
|
28
28
|
|
|
29
29
|
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|