Skip to content

Releases

4.2.10

Choose a tag to compare

@github-actions github-actions released this 09 Nov 18:58
Immutable release. Only release title and notes can be modified.

Bug fixes

  • Contended FileLock and SoftFileLock acquisitions now raise Timeout when elapsed time reaches the requested timeout. A clock that landed exactly on the deadline previously left a waiter retrying with zero-length sleeps indefinitely (#922) by @gaborbernat.

Packaging

🐍 PyPI release

πŸ“œ Full Changelog

4.2.9

Choose a tag to compare

@github-actions github-actions released this 04 Nov 18:37
Immutable release. Only release title and notes can be modified.

Bug fixes

  • ReadWriteLock, SoftReadWriteLock and their async wrappers now raise TypeError for a blocking that is not a bool, in the constructor and on acquire, as FileLock already does. Before, blocking=0 waited out the full timeout on a contended ReadWriteLock while blocking=False failed at once, and a truthy value such as "false" turned a single attempt into a blocking wait (#908) by @abhishekcpp007 and @gaborbernat.

New Contributors

🐍 PyPI release

πŸ“œ Full Changelog

4.2.8

Choose a tag to compare

@github-actions github-actions released this 04 Nov 07:47
Immutable release. Only release title and notes can be modified.

Documentation

  • Clarify the platform-specific locking primitive and range used by descriptor locks, and correct the guidance on interoperating with byte-range lock protocols such as conda's repodata lock (#905) by @boyfeiyu.

New Contributors

🐍 PyPI release

πŸ“œ Full Changelog

4.2.7

Choose a tag to compare

@github-actions github-actions released this 02 Nov 16:10
Immutable release. Only release title and notes can be modified.

Bug fixes

  • A SoftFileLease reclaims a dead holder's lease marker even when that holder published another lease_duration. It used to raise LeaseSettingsMismatch on every attempt instead, so after a holder crashed and its peers restarted with a changed duration the lock stayed wedged until force_break(). A live holder with another duration still raises (#900) by @dxbjavid and @gaborbernat.

PyPI release

Full Changelog

4.2.6

Choose a tag to compare

@github-actions github-actions released this 31 Oct 15:10
Immutable release. Only release title and notes can be modified.

Bug fixes

  • Fix a race in SoftFileLock, MarkerSoftFileLock and SoftFileLease when three or more contenders reclaim a dead marker. The race could strand a live holder's marker under a break name, leaving the lock unusable or admitting a second holder. Contenders now recheck the marker before exchanging names and unwind nested exchanges in order. If the filesystem refuses a return exchange, the contender leaves its marker at the lock path for later recovery (#899) by @dxbjavid and @gaborbernat.

PyPI release

Full Changelog

4.2.5

Choose a tag to compare

@github-actions github-actions released this 30 Oct 19:27
Immutable release. Only release title and notes can be modified.

Bug fixes

  • acquire and acquire raise TypeError for a blocking that is not a bool, as the constructor and the blocking setter already do. A truthy value such as the string "false" used to count as True, so a call meant as a single attempt waited for the instance's timeout, and without a limit at the default -1 (#870) by @simpleqt and @gaborbernat.
  • A SoftFileLock acquisition whose first read of its new marker's identity failed reads it again before rolling back. On Windows the rollback could otherwise not recognize the marker it had created, and the empty marker it left blocked the path for every later acquisition, since no contender breaks an empty marker (#869) by @simpleqt and @gaborbernat.
  • A fork() child of a process holding a SoftFileLease starts from an unheld claim. It used to inherit the parent's token, last compromise and heartbeat, so token and compromise reported a claim the child never held while is_locked reported it unheld (#868) by @dxbjavid and @gaborbernat.
  • A nested acquire of a held FileLock or SoftFileLock no longer creates the lock file's parent directory. After a rename of that directory during the hold, the nested acquire recreated the old name, and when a file had taken the name it raised FileExistsError and left the hold's recursion count incremented (#878) by @0x5t4l1n and @gaborbernat.
  • Fix ReadWriteLock failing every acquire with "link directory ... was replaced while opening" in a group-writable directory whose inherited ACL, such as an NFSv4 one on ZFS, opens the link directory to the group. The lock now closes the empty link directory to its owner, and where the filesystem refuses that, such as ZFS with aclmode=restricted, it names the directory to make writable by its owner only (#898) by @gaborbernat.
  • Fix SoftFileLock, MarkerSoftFileLock and SoftFileLease raising OverflowError out of acquire(), or never reclaiming a dead holder's lock, when a stranded restore claim beside the lock names a process number outside 1..2**31-1 or spells it in non-ASCII digits. Such a claim is now ignored, as no filelock writes one (#871) by @dxbjavid and @gaborbernat.
  • Fix soft locks on Windows keeping the marker of a holder that has exited while another process still holds a handle to it, such as a parent's subprocess.Popen after wait() or multiprocessing.Process after join(). Acquiring such a lock with the default timeout=-1 waited forever (#874) by @nk-batman21.
  • Fix the read-only reopen of a lock file this account cannot write resolving a relative path against the working directory of the moment. A chdir between the refused O_RDWR open and the reopen made the acquisition wait on a file that is not there, or probe one in another directory. The reopen now uses the path the acquisition pinned (#889) by @dxbjavid and @gaborbernat.
  • Handle EMLINK, the error FreeBSD reports when a no-follow open refuses a symlink, in a soft reader/writer lock's protocol tree, so heartbeat reports lost ownership there rather than a transient refresh error (#866) by @pacocartones and @gaborbernat.
  • Resolving ReadWriteLock or AsyncReadWriteLock raises the ImportError when a module other than Python's sqlite3 is missing, as in a frozen application that left out a filelock submodule. The names are None only without SQLite (#880) by @pintu544 and @gaborbernat.

Documentation

  • The lock-probing recipe in the how-to guide probes with blocking=False instead of a tiny timeout (#873) by @tongwentao and @gaborbernat.

Packaging

  • Releases now run on the shared tox-dev/github-workflows pipeline, with a locked release toolchain and generated GitHub Release notes (#885) by @gaborbernat.

New Contributors

PyPI release

Full Changelog

4.2.4

Choose a tag to compare

@github-actions github-actions released this 19 Oct 01:58
Immutable release. Only release title and notes can be modified.

4.2.3

Choose a tag to compare

@github-actions github-actions released this 19 Oct 00:33
Immutable release. Only release title and notes can be modified.

Bug fixes

  • Creating a lock on a Python 3.15 interpreter without types.LazyImportType no longer triggers AttributeError at exit. #861 by @gaborbernat.
  • Handle EFTYPE when a no-follow open refuses a symlink in a soft reader/writer lock's protocol tree, so heartbeat reports lost ownership rather than a transient refresh error. #859 by @edsonsims.

New Contributors

🐍 PyPI release

πŸ“œ Full Changelog

4.2.2

Choose a tag to compare

@gaborbernat gaborbernat released this 18 Oct 07:26
Immutable release. Only release title and notes can be modified.

Bug fixes

  • Fix a lock on a relative path that stayed held after a later with lock: ended, when an earlier acquire() had failed because the working directory no longer exists. That call still raises FileNotFoundError, and it now leaves the lock's hold count unchanged. #856 by @spicysharkco.

New Contributors

🐍 PyPI release

πŸ“œ Full Changelog

4.2.1

Choose a tag to compare

@gaborbernat gaborbernat released this 17 Oct 16:48
Immutable release. Only release title and notes can be modified.

Security

This release fixes the following vulnerabilities:

  • CVE-2026-112940 (high): ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user's process overwrite or unlink its own files.
  • CVE-2026-112906 (medium): SoftFileLock evicts a fresh lock file whose watched age another local user's pre-dated file passed on through inode reuse.
  • CVE-2026-112908 (medium): StrictSoftFileLock creates its claim directories without the lock mode, so another local user with a write bit on them can end a live hold.
  • CVE-2026-112909 (medium): UnixFileLock truncates and chmods any regular file another user renames or hard-links onto the lock path.
  • CVE-2026-112910 (medium): WindowsFileLock ignores mode: a 0o600 lock file and the ReadWriteLock database inherit the directory ACL.
  • CVE-2026-112911 (medium): StrictSoftFileLock and SoftReadWriteLock adopt a protocol directory another user created first, losing mutual exclusion.
  • CVE-2026-112914 (medium): SoftFileLock stale-break restore follows a swapped-in symbolic link and hard-links a file of the user running the lock into the lock directory.
  • CVE-2026-112915 (medium): ReadWriteLock: a crafted lock database makes every acquire stall or hang regardless of timeout.
  • CVE-2026-112934 (medium): SoftReadWriteLock holder refresh writes through a hard link and hangs on a named pipe that another local user renames over its record.
  • CVE-2026-112935 (medium): SoftFileLock stale-lock break removes a live lock file on a reused inode number and admits two holders.
  • CVE-2026-112937 (medium): ReadWriteLock on the hard-link route deletes any directory another user renames onto its .filelock-* link directory name.
  • CVE-2026-112938 (medium): StrictSoftFileLock follows a symbolic link swapped in at .filelock and creates claim files in a directory another local user chooses.
  • CVE-2026-112939 (medium): SoftFileLock removes a live holder's marker when another user forges the PID in a writable marker.
  • CVE-2026-112907 (low): On Windows an oplock on a soft lock's marker holds SoftFileLock.acquire() past its timeout and blocks the stale break.
  • CVE-2026-112912 (low): Symlink swap during SoftFileLock's writability check leaks whether a path exists and is writable by the lock taker.
  • CVE-2026-112913 (low): ReadWriteLock on Windows acts on SQLite side files another local user places beside its database.
  • CVE-2026-112941 (low): SoftReadWriteLock follows a lock tree swapped in after its first acquire and writes lock records into directories of the user running the lock.

Bug fixes

  • On a singleton wrapper, AsyncReadWriteLock.close() and AsyncSoftReadWriteLock.close() end only the holds that tasks acquired through that wrapper. A reader that arrives during close() gets the closed error instead of joining the ending hold. After synchronous code closes or force-releases the shared lock, the wrappers refuse to admit readers into the ended hold, and close() on such a wrapper returns. Closing one wrapper no longer ends a task's nested hold taken through another wrapper on the same path. #832 by @gaborbernat.
  • ReadWriteLock locks again after a release() that an exception from a signal handler interrupted. The async read-write wrappers stop admitting readers into such a level. The async read-write locks forget a hold whose backend release failed after the backend let go, and they free the memory of each acquire that times out or is canceled. AsyncFileLock returns from release() after a few hundred acquires gave up behind a waiting one. An exception from a signal handler delivered while an AsyncFileLock call joins its queue no longer blocks every later call on that lock. #833 by @gaborbernat.
  • Fix ReadWriteLock acting on -journal, -wal or -shm files another process puts beside its database: a write could land in another file, a reader could get in beside a writer, and an acquire could fail. SQLite now opens the database by name only in a directory no other account can write, and through a private hard link elsewhere. On Windows the directory's access control list decides. Where hard links are unavailable, keep the database in a directory other accounts cannot write, such as one under %LOCALAPPDATA%. The lock removes link directories through a checked descriptor rather than by name, reads a link directory's name only when the locking account owns it, and leaves alone a directory with other content renamed onto a link directory's name. A database whose schema takes more than a few kilobytes to load raises ValueError instead of running past the acquire timeout. #834 by @gaborbernat.
  • Fix five bugs in opening the lock file. UnixFileLock no longer truncates a file it did not create, such as one renamed to the lock path, and no longer applies mode to it. An on_acquired hook that writes holder metadata now truncates the file itself. A lease (Linux) or an oplock (Windows) on the lock file or a soft lock's marker no longer holds acquire() past its timeout or blocking=False, and an oplock no longer holds release(); ReadWriteLock on Windows waits for its timeout and raises Timeout. On Windows, a mode without group and other bits, such as 0o600, now creates the lock file with an owner-only permission list; the ReadWriteLock database gets the same. The soft locks' writability check no longer follows a symlink swapped in at the lock path. On a filesystem without flock, a contender from another account now waits on a marker it cannot write instead of raising PermissionError. #835 by @gaborbernat.
  • Fix SoftFileLock, MarkerSoftFileLock and SoftFileLease removing a live holder's marker in three cases: the holder and the contender run in Linux time namespaces with different boottime offsets; only one of them can read the boot id; a process other than the owner rewrote the marker. Soft markers no longer carry group or other write bits. A process name containing a carriage return or another line separator no longer makes the stale check raise ValueError. When /proc/self/ns/time exists but cannot be read, the stale check no longer compares start times and keeps the marker. #836 by @gaborbernat.
  • The async read-write locks record their hold under a task owner, so synchronous code on the executor thread that took the hold can no longer re-enter or release it. AsyncSoftReadWriteLock gives back one level on release, so synchronous readers of a shared singleton keep theirs. SoftReadWriteLock tracks read levels per thread: release() from a thread that holds none raises RuntimeError. After its heartbeat recorded a lost hold, it refuses new acquires until that hold is released. #838 by @gaborbernat.
  • StrictSoftFileLock creates <path>.filelock and its claims directory with the lock's mode and sets the sticky bit (a directory flag that lets only a file's owner remove it) on both. On the next acquisition it narrows a directory it owns that an earlier release created wider; it leaves a directory of another account as it is, so remove such leftovers by hand. It reaches claims through a descriptor opened without following symlinks; on Windows it holds both directories open and refuses a junction (a directory that points at another directory). Under a sticky parent such as /tmp it refuses a coordination directory of another account, as SoftReadWriteLock does for <path>.rw. One read grace now covers a whole claim scan, a failed claim cleanup no longer leaves the sentinel descriptor open, and a non-regular node at a sentinel private-record name raises SoftFileLockProtocolError. On Windows, contenders read claims without blocking their owner's unlink. #839 by @gaborbernat.
  • Fix a lock reporting a hold the OS had dropped after a signal handler raised during acquire or release. A release that a signal handler cuts short after it has started now completes before the error propagates. A handler that acquires the ...
Read more