Skip to content

Releases

4.3.1

Choose a tag to compare

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

New Contributors

🐍 PyPI release

📜 Full Changelog

4.3.0

Choose a tag to compare

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

Features

  • On Windows, release_with_timeout limits the caller's wait for release. If it raises ReleasePendingError, call wait on the exception from any thread for the result. On POSIX, release is synchronous (#1107) by @gaborbernat. (#1100)

Bug fixes

  • lock_descriptor raises TypeError unless blocking is a bool (#969) by @feiiiiii5 and @gaborbernat.
  • On POSIX filesystems with atomic exchange, SoftFileLock restores a live marker after an interrupted exchange and removes its own unfinished marker during cleanup (#1080) by @gaborbernat. (#993)
  • Unix soft fallback markers exclude group and other writes even on filesystems without atomic exchange (#1057) by @gaborbernat. (#994)
  • SoftFileLock, MarkerSoftFileLock and SoftFileLease remove empty markers after a signal interrupts marker creation or stale-marker replacement (#1049) by @gaborbernat. (#996)
  • Unix locks select the soft fallback per resolved path, including after a directory change. The lock keeps its Unix type and supports pid, is_lock_held_by_us, break_lock() and lifetime during fallback (#1057) by @gaborbernat. (#1000)
  • On POSIX, ReadWriteLock and AsyncReadWriteLock raise RuntimeError in detected subinterpreters, including InterpreterPoolExecutor workers and mod_wsgi or uWSGI subinterpreters. Use the main interpreter or a separate process. Detection on embedded CPython 3.11 requires _xxsubinterpreters or ctypes access to the interpreter C API (#1106) by @gaborbernat. (#1003)
  • On Windows, SoftFileLock treats a symlink as an occupied marker and leaves its target untouched (#1049) by @gaborbernat. (#1009)
  • SoftFileLock and SoftFileLease clean up markers and descriptors across interrupted acquires and releases. POSIX unlink errors propagate, with a retry after close on filesystems that require it. Retry release if a timeout interrupts restoration of a displaced marker (#1062) by @gaborbernat. (#1014)
  • A singleton shared by relative and absolute paths refuses acquisition if a directory change redirects its stored lock path (#1098) by @gaborbernat. (#1018)
  • ReadWriteLock raises RuntimeError if a directory change redirects a singleton's cached database path (#1058) by @gaborbernat. (#1019)
  • SoftFileLock, MarkerSoftFileLock and SoftFileLease remove their pending recovery marker even if another process replaces the break name during rollback (#1082) by @gaborbernat. (#1025)
  • Single-threaded SQLite read and write lock waits allow Python signal handlers to run. Waiting writers keep their place ahead of new readers (#1105) by @gaborbernat. (#1027)
  • On POSIX, SoftFileLock tries to leave a one-byte recovery record if a full filesystem prevents marker cleanup. With atomic exchange, a later caller can reclaim it when space is available (#1101) by @Yshuro and @gaborbernat. (#1029)
  • Windows soft-lock recovery no longer reads proc/self/ns/pid from the drive root when identifying a marker's host (#1036) by @gaborbernat.
  • On Unix filesystems without flock, waiters can reclaim an interrupted acquire's recovery marker after two seconds if atomic exchange and space for the marker are available (#1057) by @gaborbernat. (#1046)
  • SoftReadWriteLock recreates a missing generation directory during read or write acquisition, even if a holder record survives (#1103) by @gaborbernat. (#1102)
  • On POSIX, soft locks close the inspection descriptor if opening an existing marker is interrupted (#1113) by @gaborbernat. (#1111)
  • Unix locks can use the soft fallback when the directory denies the temporary probe and atomic exchange is unavailable. If native locking works there, new lock files exclude group and other writes by default. Set mode=0o660 for group sharing. The probe removes its temporary name before testing and closes its descriptor on interruption (#1115) by @gaborbernat. (#1112)
  • ReadWriteLock prevents database redirection in shared, non-sticky directories by placing its hard link in a fresh private directory. Cleanup recognizes older link layouts (#1096) by @gaborbernat.
  • AsyncFileLock, AsyncReadWriteLock and AsyncSoftReadWriteLock discard executor calls whose submission failed. A queued release can no longer drop a later task's lock (#986) by @gaborbernat.
  • SoftReadWriteLock scans up to 256 orphan holder records and 256 temporary files per sweep, resuming where it stopped. Each listing removes up to 256 obsolete generations. The lock raises a protocol error above 65,536 generation entries (#1097) by @gaborbernat.
  • SoftReadWriteLock uses fixed-size fingerprints to bound memory use per holder record during cleanup (#1097) by @gaborbernat.
  • StrictSoftFileLock backs off above 1,024 public claims and raises SoftFileLockProtocolError above 16,380 directory entries before publication. Sentinel cleanup counts only the lock's own records (#1040) by @gaborbernat.
  • StrictSoftFileLock creates sentinels and claims without group or other write permissions. Run chmod go-w on older writable sentinels. On Linux, a contender waits if fs.protected_hardlinks prevents it from probing another account's claim (#985) by @gaborbernat.
  • Timeout and lock_path_occupant now escape control characters and other bytes outside printable non-space ASCII in recorded hostnames (#1090) by @radhika1314 and @gaborbernat.
  • A SoftReadWriteLock heartbeat checks the holder token before writing. If another file replaces the record and reuses its inode, the lock reports a lost hold (#982) by @gaborbernat.
  • A SoftReadWriteLock waiter paused past stale_threshold gets a fresh token so cleanup of its old record cannot remove the new hold (#1097) by @gaborbernat.
  • A failed acquire rolls back its own nesting level. Releasing that level from a hook or signal handler raises RuntimeError. Balanced nested holds still work. Retrying an interrupted release on a shared instance affects only the original hold. An indefinite acquire raises RuntimeError if a signal handler returns holding the same path through another instance (#1060) by @gaborbernat.
  • A forked child with its parent's numeric PID in another Linux PID namespace preserves the parent's locks and private SQLite database link (#1075) by @gaborbernat.
  • After an ambiguous Unix unlock error, FileLock rejects reentrant acquires until an explicit release() retry resolves the hold (#1098) by @gaborbernat.
  • Async reader/writer wrappers sharing a lock serve waiting writers in arrival order, ahead of new readers. Returning writers rejoin at the back (#1073) by @gaborbernat.
  • At interpreter exit, SoftReadWriteLock keeps holds owned by live daemon threads. AsyncSoftReadWriteLock keeps holds whose event loops are still running (#1048) by @gaborbernat.
  • Canceling an AsyncFileLock release still decrements the lock counter after the active transition finishes (#1051) by @gaborbernat.
  • Closing an async reader/writer wrapper stops its contended acquires on the next poll, even if another singleton wrapper is waiting (#1073) by @gaborbernat.
  • Closing an async reader/writer wrapper wakes tasks waiting on that wrapper even if another singleton wrapper holds the lock (#1073) by @gaborbernat.
  • During shutdown, another thread's release(force=True) preserves the main thread's thread-local hold, including during atexit callbacks...
Read more

4.2.12

Choose a tag to compare

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

Bug fixes

  • UnixFileLock refuses, with PermissionError, a lock file that another account owns under a sticky parent such as /tmp. Its owner could remove it during a hold, after which a second process locked a new file at the same path and both held the lock. A file owned by the directory's owner, such as root in /tmp, is still accepted (#968) by @gaborbernat.

🐍 PyPI release

📜 Full Changelog

4.2.11

Choose a tag to compare

@github-actions github-actions released this 17 Nov 06:36
Immutable release. Only release title and notes can be modified.

Bug fixes

  • AsyncStrictSoftFileLock with a poll_interval below 0.05 seconds now spreads contended retries across a jittered, widening window like StrictSoftFileLock, instead of a fixed interval (#928) by @feiiiiii5 and @gaborbernat.
  • SoftReadWriteLock on runtimes without dir_fd other than Windows, such as GraalPy, now refuses a protocol directory another account owns under a sticky parent, as the other platforms already do (#940) by @gaborbernat.
  • A SoftFileLease garbage collected on its own heartbeat thread no longer deadlocks that thread, which left every later os.fork() in the process waiting forever (#949) by @gaborbernat.
  • A lock dropped during interpreter shutdown, including a ReadWriteLock or AsyncReadWriteLock, no longer prints an ignored exception at exit (#933) by @kushaldave002 and @gaborbernat.
  • A lock still referenced when the interpreter exits is released from an atexit handler before module teardown, except holds of daemon threads that are still running, and a thread_local=False lock while any other thread runs (#964) by @gaborbernat.
  • On Windows, lock paths that differ only in drive letter or UNC share case, such as C:\work.lock and c:\work.lock, now share one FileLock or SoftReadWriteLock singleton and trigger FileLock's same-thread deadlock detection (#929) by @subotac and @gaborbernat.
  • Releasing a soft lock whose marker a peer replaced no longer raises AttributeError on GraalPy, which lacks os.pwrite (#940) by @gaborbernat.
  • os.fork() no longer waits forever for a lock transition another thread never finishes; after 30 seconds the child exits with status 70 and the parent continues (#949) by @gaborbernat.

New Contributors

🐍 PyPI release

📜 Full Changelog

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