filelock 4.2.1__tar.gz → 4.2.2__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.
- {filelock-4.2.1 → filelock-4.2.2}/PKG-INFO +1 -1
- {filelock-4.2.1 → filelock-4.2.2}/docs/changelog.rst +8 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_api.py +1 -2
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/version.py +2 -2
- {filelock-4.2.1 → filelock-4.2.2}/tests/soft_rw/test_soft_rw_protocol.py +18 -5
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_filelock.py +42 -0
- {filelock-4.2.1 → filelock-4.2.2}/.gitignore +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/LICENSE +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/README.md +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/_static/custom.css +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/api.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/changelog/template.jinja2 +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/concepts.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/conf.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/example.gif +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/how-to.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/index.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/license.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/logo.svg +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/docs/tutorials.rst +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/pyproject.toml +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/__init__.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_async.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_async_read_write.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_descriptor.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_error.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_identity.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_lease.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_marker.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_read_write.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_protocol.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_rw/__init__.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_rw/_async.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_rw/_protocol.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_rw/_storage.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_soft_rw/_sync.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_strict.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_unix.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_util.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/_windows.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/asyncio.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/src/filelock/py.typed +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/benchmark.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/capabilities.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/capability/assert_fallback.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/capability/sitecustomize.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/coverage_pragmas.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/deny_symlink.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/termux/Dockerfile +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tasks/verify_filesystem.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/async_filelock_cancellation_helpers.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/capability_marks.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/conftest.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/fork_helpers.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/pid_namespace_helpers.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/process_helpers.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/read_write_helpers.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/soft_rw/conftest.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/soft_rw/test_soft_rw_async.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/soft_rw/test_soft_rw_storage.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/soft_rw/test_soft_rw_sync.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock_acquire_cancellation.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock_release_cancellation.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock_rollback_agnostic.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock_runner_shutdown.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_filelock_transition_admission.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_read_write.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_read_write_cancel_wait.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_read_write_cancellation.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_read_write_worker_ownership.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_soft_contracts.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_async_transition_gate.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_default_mode.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_error.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_fork_backends.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_fork_coordination.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_fork_ownership.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_fork_registries.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_host_name_grammar.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_lazy_import.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_lifetime_validation.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_lock_expiry.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_marker_records.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_process_identity.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_read_write.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_read_write_fork.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_read_write_private_link.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_read_write_unit.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_soft_lease.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_soft_lifetime_warning.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_soft_stale.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_compat.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_failures.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_paths.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_races.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_recovery.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_strict_soft_stress.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_subclass_options.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_unix_fallback.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_util.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tests/test_virtualenv.py +0 -0
- {filelock-4.2.1 → filelock-4.2.2}/tox.toml +0 -0
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
.. towncrier release notes start
|
|
8
8
|
|
|
9
|
+
*******************
|
|
10
|
+
4.2.2 (2026-10-18)
|
|
11
|
+
*******************
|
|
12
|
+
|
|
13
|
+
- Fix a lock on a relative path that stayed held after a later ``with lock:`` ended, when an earlier ``acquire()`` had
|
|
14
|
+
failed because the working directory no longer exists. That call still raises :class:`FileNotFoundError`, and it now
|
|
15
|
+
leaves the lock's hold count unchanged. :pr:`856`
|
|
16
|
+
|
|
9
17
|
*******************
|
|
10
18
|
4.2.1 (2026-10-17)
|
|
11
19
|
*******************
|
|
@@ -1217,10 +1217,9 @@ class BaseFileLock(contextlib.ContextDecorator, metaclass=FileLockMeta): # ruff
|
|
|
1217
1217
|
if _on_this_stack(self._context.releasing):
|
|
1218
1218
|
msg = f"lock '{self.lock_file}' is acquired again while this thread's release of it runs"
|
|
1219
1219
|
raise RuntimeError(msg)
|
|
1220
|
-
|
|
1220
|
+
canonical = _canonical(self.lock_file)
|
|
1221
1221
|
self._context.lock_counter += 1
|
|
1222
1222
|
|
|
1223
|
-
canonical = _canonical(self.lock_file)
|
|
1224
1223
|
self._raise_if_would_deadlock(canonical, timeout=timeout, blocking=blocking)
|
|
1225
1224
|
if not self.is_locked:
|
|
1226
1225
|
self._pin_lock_path(canonical)
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '4.2.
|
|
22
|
-
__version_tuple__ = version_tuple = (4, 2,
|
|
21
|
+
__version__ = version = '4.2.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (4, 2, 2)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -30,6 +30,7 @@ from filelock._soft_rw._protocol import (
|
|
|
30
30
|
Ledger,
|
|
31
31
|
Participant,
|
|
32
32
|
Snapshot,
|
|
33
|
+
TreeReplacedError,
|
|
33
34
|
encode_holder,
|
|
34
35
|
holder_lease,
|
|
35
36
|
parse_snapshot,
|
|
@@ -884,13 +885,25 @@ def test_heartbeat_ignores_a_broken_successor_record(lock_file: str, files: OsFi
|
|
|
884
885
|
|
|
885
886
|
|
|
886
887
|
@pytest.mark.requires_hard_links
|
|
887
|
-
|
|
888
|
-
|
|
888
|
+
@pytest.mark.parametrize(
|
|
889
|
+
("error", "expected"),
|
|
890
|
+
[
|
|
891
|
+
pytest.param(OSError(EIO, "Input/output error"), "transient", id="filesystem-error"),
|
|
892
|
+
pytest.param(TreeReplacedError("tree replaced"), "lost", id="replaced-tree"),
|
|
893
|
+
],
|
|
894
|
+
)
|
|
895
|
+
def test_heartbeat_reports_the_refresh_error(
|
|
896
|
+
lock_file: str,
|
|
897
|
+
files: OsFiles,
|
|
898
|
+
mocker: MockerFixture,
|
|
899
|
+
error: OSError | TreeReplacedError,
|
|
900
|
+
expected: Literal["transient", "lost"],
|
|
901
|
+
) -> None:
|
|
902
|
+
writer: Final[Participant] = _participant(files, lock_file, "write")
|
|
889
903
|
writer.publish()
|
|
890
904
|
assert writer.advance()
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
assert writer.heartbeat() == ("transient", error)
|
|
905
|
+
mocker.patch.object(OsFiles, "overwrite", autospec=True, side_effect=error)
|
|
906
|
+
assert writer.heartbeat() == (expected, error if isinstance(error, OSError) else None)
|
|
894
907
|
|
|
895
908
|
|
|
896
909
|
def test_heartbeat_without_a_published_record_is_lost(lock_file: str, files: OsFiles) -> None:
|
|
@@ -3213,6 +3213,48 @@ def test_each_acquisition_resolves_the_working_directory(
|
|
|
3213
3213
|
assert (lock.lock_file, (second / "resource.lock").exists()) == ("resource.lock", True)
|
|
3214
3214
|
|
|
3215
3215
|
|
|
3216
|
+
@pytest.mark.skipif(
|
|
3217
|
+
sys.platform == "win32", reason="a working directory in use cannot be removed"
|
|
3218
|
+
) # pragma: win32 no cover
|
|
3219
|
+
@pytest.mark.parametrize("lock_type", _RELATIVE_LOCK_TYPES)
|
|
3220
|
+
def test_acquire_without_working_directory_leaves_no_hold(
|
|
3221
|
+
lock_type: type[BaseFileLock], working_directories: tuple[Path, Path]
|
|
3222
|
+
) -> None:
|
|
3223
|
+
lock: Final[BaseFileLock] = lock_type("resource.lock")
|
|
3224
|
+
working_directories[0].rmdir()
|
|
3225
|
+
|
|
3226
|
+
with pytest.raises(FileNotFoundError):
|
|
3227
|
+
lock.acquire()
|
|
3228
|
+
second: Final[Path] = working_directories[1]
|
|
3229
|
+
os.chdir(second)
|
|
3230
|
+
with lock:
|
|
3231
|
+
assert (lock.lock_counter, lock.is_locked, (second / "resource.lock").exists()) == (1, True, True)
|
|
3232
|
+
|
|
3233
|
+
assert (lock.lock_counter, lock.is_locked) == (0, False)
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
@pytest.mark.skipif(
|
|
3237
|
+
sys.platform == "win32", reason="a working directory in use cannot be removed"
|
|
3238
|
+
) # pragma: win32 no cover
|
|
3239
|
+
@pytest.mark.parametrize("lock_type", _RELATIVE_LOCK_TYPES)
|
|
3240
|
+
def test_nested_acquire_without_working_directory_preserves_hold(
|
|
3241
|
+
lock_type: type[BaseFileLock], working_directories: tuple[Path, Path]
|
|
3242
|
+
) -> None:
|
|
3243
|
+
lock: Final[BaseFileLock] = lock_type("resource.lock")
|
|
3244
|
+
lock.acquire()
|
|
3245
|
+
first: Final[Path] = working_directories[0]
|
|
3246
|
+
(first / "resource.lock").unlink()
|
|
3247
|
+
first.rmdir()
|
|
3248
|
+
|
|
3249
|
+
with pytest.raises(FileNotFoundError):
|
|
3250
|
+
lock.acquire()
|
|
3251
|
+
assert (lock.lock_counter, lock.is_locked) == (1, True)
|
|
3252
|
+
|
|
3253
|
+
os.chdir(working_directories[1])
|
|
3254
|
+
lock.release()
|
|
3255
|
+
assert (lock.lock_counter, lock.is_locked) == (0, False)
|
|
3256
|
+
|
|
3257
|
+
|
|
3216
3258
|
@pytest.mark.parametrize("lock_type", _RELATIVE_LOCK_TYPES)
|
|
3217
3259
|
def test_singleton_after_chdir_locks_the_requested_file(
|
|
3218
3260
|
lock_type: type[BaseFileLock], working_directories: tuple[Path, Path]
|
|
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
|
|
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
|
|
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
|