.. towncrier-draft-entries:: Unreleased
- :class:`~filelock.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 asrootin/tmp, is still accepted (:pr:`968`) by :user:`gaborbernat`.
- :class:`~filelock.AsyncStrictSoftFileLock` with a
poll_intervalbelow 0.05 seconds now spreads contended retries across a jittered, widening window like :class:`~filelock.StrictSoftFileLock`, instead of a fixed interval (:pr:`928`) by :user:`feiiiiii5` and :user:`gaborbernat`. - :class:`~filelock.SoftReadWriteLock` on runtimes without
dir_fdother than Windows, such as GraalPy, now refuses a protocol directory another account owns under a sticky parent, as the other platforms already do (:pr:`940`) by :user:`gaborbernat`. - A :class:`~filelock.SoftFileLease` garbage collected on its own heartbeat thread no longer deadlocks that thread,
which left every later
os.fork()in the process waiting forever (:pr:`949`) by :user:`gaborbernat`. - A lock dropped during interpreter shutdown, including a
ReadWriteLockorAsyncReadWriteLock, no longer prints an ignored exception at exit (:pr:`933`) by :user:`kushaldave002` and :user:`gaborbernat`. - A lock still referenced when the interpreter exits is released from an
atexithandler before module teardown, except holds of daemon threads that are still running, and athread_local=Falselock while any other thread runs (:pr:`964`) by :user:`gaborbernat`. - On Windows, lock paths that differ only in drive letter or UNC share case, such as
C:\work.lockandc:\work.lock, now share one :class:`~filelock.FileLock` or :class:`~filelock.SoftReadWriteLock` singleton and triggerFileLock's same-thread deadlock detection (:pr:`929`) by :user:`subotac` and :user:`gaborbernat`. - Releasing a soft lock whose marker a peer replaced no longer raises
AttributeErroron GraalPy, which lacksos.pwrite(:pr:`940`) by :user:`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 (:pr:`949`) by :user:`gaborbernat`.
- Contended :class:`~filelock.FileLock` and :class:`~filelock.SoftFileLock` acquisitions now raise :class:`~filelock.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 (:pr:`922`) by :user:`gaborbernat`.
- Every wheel now carries a PEP 770 CycloneDX SBOM in its
.dist-info/sbomsdirectory, written at build time by python-sbom (:pr:`921`) by :user:`gaborbernat`.
- :class:`~filelock.ReadWriteLock`, :class:`~filelock.SoftReadWriteLock` and their async wrappers now raise
:class:`TypeError` for a blocking that is not a :class:`bool`, in the constructor and on acquire, as
:class:`~filelock.FileLock` already does. Before,
blocking=0waited out the full timeout on a contended :class:`~filelock.ReadWriteLock` whileblocking=Falsefailed at once, and a truthy value such as"false"turned a single attempt into a blocking wait (:pr:`908`) by :user:`abhishekcpp007` and :user:`gaborbernat`.
- 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 (:pr:`905`) by :user:`boyfeiyu`.
- A :class:`~filelock.SoftFileLease` reclaims a dead holder's lease marker even when that holder published another
lease_duration. It used to raise :class:`~filelock.LeaseSettingsMismatch` on every attempt instead, so after a holder crashed and its peers restarted with a changed duration the lock stayed wedged until :meth:`force_break() <filelock.MarkerSoftFileLock.force_break>`. A live holder with another duration still raises (:pr:`900`) by :user:`dxbjavid` and :user:`gaborbernat`.
- Fix a race in :class:`~filelock.SoftFileLock`, :class:`~filelock.MarkerSoftFileLock` and :class:`~filelock.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 (:pr:`899`) by :user:`dxbjavid` and :user:`gaborbernat`.
- :meth:`~filelock.BaseFileLock.acquire` and :meth:`~filelock.BaseAsyncFileLock.acquire` raise :class:`TypeError` for a
blocking that is not a :class:`bool`, as the constructor and the
blockingsetter already do. A truthy value such as the string"false"used to count asTrue, so a call meant as a single attempt waited for the instance'stimeout, and without a limit at the default-1(:pr:`870`) by :user:`simpleqt` and :user:`gaborbernat`. - A :class:`~filelock.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 (:pr:`869`) by :user:`simpleqt` and :user:`gaborbernat`.
- A
fork()child of a process holding a :class:`~filelock.SoftFileLease` starts from an unheld claim. It used to inherit the parent's token, last compromise and heartbeat, so :attr:`~filelock.SoftFileLease.token` and :attr:`~filelock.SoftFileLease.compromise` reported a claim the child never held whileis_lockedreported it unheld (:pr:`868`) by :user:`dxbjavid` and :user:`gaborbernat`. - A nested acquire of a held :class:`~filelock.FileLock` or :class:`~filelock.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 :class:`FileExistsError` and left the hold's recursion count incremented (:pr:`878`) by :user:`0x5t4l1n` and :user:`gaborbernat`.
- Fix :class:`ReadWriteLock <filelock.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 (:pr:`898`) by :user:`gaborbernat`. - Fix :class:`~filelock.SoftFileLock`, :class:`~filelock.MarkerSoftFileLock` and :class:`~filelock.SoftFileLease`
raising
OverflowErrorout ofacquire(), or never reclaiming a dead holder's lock, when a stranded restore claim beside the lock names a process number outside1..2**31-1or spells it in non-ASCII digits. Such a claim is now ignored, as no filelock writes one (:pr:`871`) by :user:`dxbjavid` and :user:`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.Popenafterwait()ormultiprocessing.Processafterjoin(). Acquiring such a lock with the defaulttimeout=-1waited forever (:pr:`874`) by :user:`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
chdirbetween the refusedO_RDWRopen 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 (:pr:`889`) by :user:`dxbjavid` and :user:`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 (:pr:`866`) by :user:`pacocartones` and :user:`gaborbernat`. - Resolving :class:`~filelock.ReadWriteLock` or :class:`~filelock.AsyncReadWriteLock` raises the :exc:`ImportError` when
a module other than Python's :mod:`sqlite3` is missing, as in a frozen application that left out a filelock submodule.
The names are
Noneonly without SQLite (:pr:`880`) by :user:`pintu544` and :user:`gaborbernat`.
- The lock-probing recipe in the how-to guide probes with
blocking=Falseinstead of a tinytimeout(:pr:`873`) by :user:`tongwentao` and :user:`gaborbernat`.
- Releases now run on the shared tox-dev/github-workflows pipeline, with a locked release toolchain and generated GitHub Release notes (:pr:`885`) by :user:`gaborbernat`.
- Creating a lock on a Python 3.15 interpreter without
types.LazyImportTypeno longer triggersAttributeErrorat exit. :pr:`861` - by :user:`gaborbernat`. - Handle
EFTYPEwhen 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. :pr:`859` - by :user:`edsonsims`.
- Fix a lock on a relative path that stayed held after a later
with lock:ended, when an earlieracquire()had failed because the working directory no longer exists. That call still raises :class:`FileNotFoundError`, and it now leaves the lock's hold count unchanged. :pr:`856` - by :user:`spicysharkco`.
- On a singleton wrapper, :meth:`AsyncReadWriteLock.close() <filelock.AsyncReadWriteLock.close>` and
:meth:`AsyncSoftReadWriteLock.close() <filelock.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, andclose()on such a wrapper returns. Closing one wrapper no longer ends a task's nested hold taken through another wrapper on the same path. :pr:`832` - by :user:`gaborbernat`. - :class:`~filelock.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. :class:`~filelock.AsyncFileLock` returns fromrelease()after a few hundred acquires gave up behind a waiting one. An exception from a signal handler delivered while an :class:`~filelock.AsyncFileLock` call joins its queue no longer blocks every later call on that lock. :pr:`833` - by :user:`gaborbernat`. - Fix :class:`~filelock.ReadWriteLock` acting on
-journal,-walor-shmfiles 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 :class:`ValueError` instead of running past the acquire timeout. :pr:`834` - by :user:`gaborbernat`. - Fix five bugs in opening the lock file. :class:`~filelock.UnixFileLock` no longer truncates a file it did not create,
such as one renamed to the lock path, and no longer applies
modeto it. Anon_acquiredhook 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 holdsacquire()past itstimeoutorblocking=False, and an oplock no longer holdsrelease(); :class:`~filelock.ReadWriteLock` on Windows waits for itstimeoutand raises :class:`~filelock.Timeout`. On Windows, amodewithout group and other bits, such as0o600, now creates the lock file with an owner-only permission list; the :class:`~filelock.ReadWriteLock` database gets the same. The soft locks' writability check no longer follows a symlink swapped in at the lock path. On a filesystem withoutflock, a contender from another account now waits on a marker it cannot write instead of raisingPermissionError. :pr:`835` - by :user:`gaborbernat`. - Fix :class:`~filelock.SoftFileLock`, :class:`~filelock.MarkerSoftFileLock` and :class:`~filelock.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 :class:`ValueError`. When
/proc/self/ns/timeexists but cannot be read, the stale check no longer compares start times and keeps the marker. :pr:`836` - by :user:`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. :class:`~filelock.AsyncSoftReadWriteLock` gives back one level on
release, so synchronous readers of a shared singleton keep theirs. :class:`~filelock.SoftReadWriteLock` tracks read
levels per thread:
release()from a thread that holds none raises :class:`RuntimeError`. After its heartbeat recorded a lost hold, it refuses new acquires until that hold is released. :pr:`838` - by :user:`gaborbernat`. - :class:`~filelock.StrictSoftFileLock` creates
<path>.filelockand itsclaimsdirectory with the lock'smodeand 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 reachesclaimsthrough 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/tmpit refuses a coordination directory of another account, as :class:`~filelock.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 :class:`~filelock.SoftFileLockProtocolError`. On Windows, contenders read claims without blocking their owner's unlink. :pr:`839` - by :user:`gaborbernat`. - Fix a lock reporting a hold the OS had dropped after a signal handler raised during
:meth:`~filelock.BaseFileLock.acquire` or :meth:`~filelock.BaseFileLock.release`. A release that a signal handler cuts
short after it has started now completes before the error propagates. A handler that acquires the lock its own thread
is releasing now gets :class:`RuntimeError` instead of a hold that stays held. The singleton cache no longer hands out
an
is_singleton=Truelock or a :class:`~filelock.ReadWriteLock` whose finalizer is running, which released the new holder's lock. A signal duringos.fork()no longer leaves the other threads blocked in their next lock call, and a fork from another thread no longer waits for a :class:`~filelock.ReadWriteLock` acquire on a busy database. :pr:`840` - by :user:`gaborbernat`. - Fix a lock on a relative path locking a file in the directory the process changed to while the lock waited, and
leaving its marker behind on release after such a change. The path resolved when an acquisition starts stays in use
until the hold ends. An
is_singleton=Truelookup no longer returns a cached lock whose relative path now resolves to another file; a held lock still matches the file it holds. A rename of the lock's directory during a hold no longer leaves the marker behind or reports a false lease compromise, and a waiter no longer creates a second lock file in a directory that was renamed away. :pr:`841` - by :user:`gaborbernat`. - :class:`~filelock.SoftReadWriteLock` reaches its records through descriptors of
<path>.rwandgenorholdersopened without following symlinks. On Windows it holds those directories open and refuses a junction (a directory that points at another directory). A tree swapped in after an earlier acquire therefore cannot redirect them. Its heartbeat rewrites a holder record only when the name still leads to the file it created, and does not block on a FIFO (a named pipe). A heartbeat that finds<path>.rwreplaced by a symlink or junction reports the hold lost instead of ending the heartbeat thread. A live lock object repeats the ownership check whenever the tree it opens is not the one it prepared. :pr:`842` - by :user:`gaborbernat`. - Fix :class:`~filelock.SoftFileLock`, :class:`~filelock.MarkerSoftFileLock` and :class:`~filelock.SoftFileLease`
removing or displacing a live holder's marker in five cases. ext4 gave a freed inode number to the next marker. A
stalled :class:`~filelock.FileLock` removed its
ENOSYSplaceholder after a peer replaced it. A failed acquire cleaned up after a successor took the path. A stale break left the lock path empty while it checked the marker it had moved. Alifetimebreak judged a marker by a reused inode number. On Linux and macOS a stale marker now changes hands in one atomic exchange. On other platforms without one, except Windows, including NFS and SMB, the marker stays in place and waits fortimeoutorbreak_lock(). Restoring a marker no longer follows a symlink found under the break name. A holder that releases while a peer's exchange has its marker aside leaves a record no lock parses, so the put-back lands a marker that ages out. A lease heartbeat that finds another file at the lock path once, while a peer's break has its marker aside, waits for the next refresh before it reports a compromise. A contender that finds a dead breaker's marker puts back the marker that breaker left under its break name. A marker is the breaker's own only when it names the breaker's process on this host; the same process number on another host is a holder. A contender takes a stranded marker under a name of its own before it puts the marker back, so two contenders no longer reverse each other's exchange and remove the live holder's marker. A claim left behind by a failed put-back is retried on the next poll. :pr:`843` - by :user:`gaborbernat`. - Canceling an :class:`~filelock.AsyncReadWriteLock` or :class:`~filelock.AsyncSoftReadWriteLock` acquire that waits for
another process now stops the wait and raises the cancellation. It used to wait until that process released, or raise
:class:`~filelock.Timeout`. A
thread_local=True:class:`~filelock.AsyncFileLock` that threads with their own event loops share no longer deadlocks when one thread waits for the lock while another holds it. :pr:`844` - by :user:`gaborbernat`. - :class:`~filelock.SoftReadWriteLock` refuses a commit that lands a whole retention window behind the log, so two committers stalled at adjacent generations can no longer admit a second writer. Its stale check samples the clock before it reads a holder record, so a pause between the two no longer counts as time the record stayed unchanged. :pr:`845` - by :user:`gaborbernat`.
- Fix a :class:`~filelock.SoftFileLock` contender evicting an empty marker after two seconds while its owner held the
lock. The owner is a
SoftFileLockbefore 3.22, which writes nothing into its marker, or a current one still writing its record. An empty marker now reads as held, andtimeout,lifetimeorbreak_lock()clears it. A contender that finds an empty marker a dead breaker left aside puts it back instead of removing it. :pr:`846` - by :user:`gaborbernat`. - Fix :class:`~filelock.ReadWriteLock` on Windows acting on
-journaland-walfiles another account places beside its database: an acquire could fail with :class:`sqlite3.OperationalError`, or SQLite could replay the journal and delete the file it names. The lock now reads the database directory's access control list. Where an account other than the locking account,SYSTEMandAdministratorscan add or remove names, SQLite opens a hard link inside a directory only those accounts can write. A filesystem without hard links raises :class:`OSError`. :pr:`854` - by :user:`gaborbernat`. - Fix
SoftReadWriteLocksubclasses sharing singleton instances with the base class or sibling subclasses. Each concrete class now keeps its own cache and construction guard, including after fork, while preserving cooperative class-definition keywords. :pr:`855` - by :user:`AryanRG`.
- Fix :class:`~filelock.StrictSoftFileLock` raising :class:`~filelock.SoftFileLockProtocolError` on Windows when a contender read a claim whose owner was still finishing its unlink. :pr:`829` - by :user:`gaborbernat`.
import filelockis about twice as fast: lock types other than :class:`~filelock.FileLock` load on first use. :pr:`831` - by :user:`gaborbernat`.
- Fix read-lock acquisition on SQLite versions older than 3.33.0 by using
sqlite_masterfor the schema probe. :pr:`827` - by :user:`DawnofGenX`. - Raise
IsADirectoryError(orPermissionErroron Windows) for a directory lock path regardless of its write permissions. :pr:`822` - by :user:`feiiiiii5`. - Fix a forked child hanging at exit on PyPy when the parent forked while an :class:`~filelock.AsyncReadWriteLock` worker thread was between two operations. :pr:`828` - by :user:`gaborbernat`.
- Hash all cache keys in the lock filename recipe so short path-like keys stay in the chosen directory. The example also accepts path-derived surrogate escapes and works before the cache directory exists. :pr:`824` - by :user:`xiehuanyi`.
- Avoid the macOS
/dev/fdlookup implicated in a kernel panic by opening SQLite through a validated hard link. The database directory must be writable and support hard links; alias creation failure raisesOSError. :pr:`820` - by :user:`gaborbernat`. - Ignore non-ASCII PID or start-time fields and out-of-range PIDs in
ReadWriteLockhard-link directory names so forged owners cannot abort acquisition. :pr:`821` - by :user:`dxbjavid`.
- Import :data:`~filelock.OwnerMode`, :data:`~filelock.CompromiseReason` and :data:`~filelock.has_fcntl` from
filelock. :pr:`790` - by :user:`gaborbernat`. - :class:`~filelock.AcquireReturnProxy` is generic in the lock type, so
with lock.acquire() as held:typesheldas the lock's own class. :pr:`803` - by :user:`gaborbernat`. - A :class:`~filelock.Timeout` from a soft lock names a holder on another host or in another PID namespace, which no contender ever reclaims. :pr:`815` - by :user:`gaborbernat`.
- Every option given in seconds takes a :class:`~decimal.Decimal` or :class:`~fractions.Fraction`, as a file lock's
timeoutalready did, and a read-write lock or lease refuses aboolor string one. :pr:`815` - by :user:`gaborbernat`.
- :attr:`~filelock.SoftFileLock.is_lock_held_by_us` and :attr:`~filelock.MarkerSoftFileLock.is_lock_held_by_us` return
Falsefor a marker an earlier process with the same PID left behind. :pr:`774` - by :user:`lprnmns`. - :class:`~filelock.SoftFileLock` removes its marker when writing it fails and closing the descriptor fails too, so the lock path no longer stays blocked. :pr:`775` - by :user:`harbinresearcher`.
- :meth:`~filelock.BaseFileLock.acquire` and :meth:`~filelock.BaseAsyncFileLock.acquire` no longer wait past
timeoutwhenpoll_intervalis longer than the time left. :pr:`777` - by :user:`feiiiiii5`. - :class:`~filelock.SoftReadWriteLock` ignores a generation-log entry whose name is not 20 ASCII digits, which used to stop its heartbeat thread or delete real generations. :pr:`778` - by :user:`dxbjavid`.
- :class:`~filelock.ReadWriteLock`, :class:`~filelock.SoftReadWriteLock` and their async wrappers treat a
:data:`math.inf` timeout like
-1and raise :class:`ValueError` for a blockingnanone. :pr:`779` - by :user:`darrenhuai`. - :class:`~filelock.ReadWriteLock` and :class:`~filelock.SoftReadWriteLock` accept a timeout above :data:`threading.TIMEOUT_MAX` instead of raising :class:`OverflowError`. :pr:`780` - by :user:`darrenhuai`.
- :meth:`~filelock.BaseFileLock.acquire` raises :class:`ValueError` for a blocking
nantimeout or apoll_intervalabove :data:`threading.TIMEOUT_MAX`, and treats a :data:`math.inf` timeout like-1. :pr:`781` - by :user:`gaborbernat`. - :class:`~filelock.SoftFileLock` and :class:`~filelock.MarkerSoftFileLock` treat a marker cut before its final newline as malformed, so a crash-truncated record self-heals and a read mid-write no longer breaks a live lock. :pr:`782` - by :user:`gaborbernat`.
- :class:`~filelock.UnixFileLock` no longer deletes another process's live marker when it falls back to a soft lock on
ENOSYS, and on macOS a lock path ending in a separator raises :class:`FileNotFoundError` instead of retrying. :pr:`785` - by :user:`gaborbernat`. - :class:`~filelock.SoftFileLock` and :class:`~filelock.SoftFileLease` put back a live successor's marker that a racing stale break moved aside, so a third contender no longer acquires beside the successor. :pr:`786` - by :user:`gaborbernat`.
- :class:`~filelock.StrictSoftFileLock` removes every claim a failed acquire published, counts an
EEXISTlink that landed as published, and no longer reportsis_lockedafter a failed claim cleanup. :pr:`787` - by :user:`gaborbernat`. - On Python 3.10 without the
exceptiongroupbackport, a release failure under the defaultcontext_error_policyno longer turns into :exc:`ModuleNotFoundError`; cleanup failures chain instead of grouping, andon_acquiredis allowed. :pr:`788` - by :user:`gaborbernat`. - :class:`~filelock.AsyncReadWriteLock` and :class:`~filelock.AsyncSoftReadWriteLock` drop a task's hold when a caller cancels it during a release that still completes, instead of blocking every later writer. :pr:`789` - by :user:`gaborbernat`.
- :class:`~filelock.SoftFileLease` releases a lease dropped while held, at garbage collection or interpreter exit, and
raises :class:`ValueError` for a
heartbeat_intervalabove :data:`threading.TIMEOUT_MAX`. :pr:`791` - by :user:`gaborbernat`. - :class:`~filelock.StrictSoftFileLock` judges an abandoned private record's age by the filesystem's clock, so a client clock ahead of an NFS server no longer aborts live publications. :pr:`792` - by :user:`gaborbernat`.
- :class:`~filelock.BaseAsyncFileLock` raises :class:`RuntimeError` instead of :class:`asyncio.CancelledError` when its executor shuts down with the call still queued, and a waiter interrupted by anything else no longer wedges later calls. :pr:`793` - by :user:`gaborbernat`.
- Constructing or closing a second :class:`~filelock.ReadWriteLock` on a held database no longer drops the holder's lock, so other processes stay excluded. :pr:`794` - by :user:`gaborbernat`.
- :class:`~filelock.SoftReadWriteLock` no longer admits a second writer after
<path>.rwis removed under a live instance, and flushes each snapshot before publishing it so a crash cannot leave an empty one that wedges every peer. :pr:`795` - by :user:`gaborbernat`. - :class:`~filelock.SoftFileLease` reclaims a dead :class:`~filelock.MarkerSoftFileLock` owner, and expires a lease or a malformed soft marker after it stays unchanged on the contender's own monotonic clock, so clock skew cannot break it. :pr:`796` - by :user:`gaborbernat`.
- A soft lock marker written in a Linux container records its PID namespace with the hostname, so a sibling container that shares the hostname and volume no longer breaks a live lock. :pr:`797` - by :user:`gaborbernat`.
- :meth:`SoftReadWriteLock.close() <filelock.SoftReadWriteLock.close>` makes an acquire still waiting in another thread raise :class:`RuntimeError`, where it used to take the lock on the closed instance and hold it until the process exited. :pr:`798` - by :user:`gaborbernat`.
- :class:`~filelock.SoftReadWriteLock` reads the head from
gen/HEAD, so a client whose cached directory listing is more than 64 generations stale no longer takes an old generation for the head and forks the log. :pr:`799` - by :user:`gaborbernat`. - When the garbage collector finalizes a held :class:`~filelock.BaseAsyncFileLock`, it releases on a
looprunning in another thread, or in place once no loop is left; thelifetimecheck and path resolution now run in the executor. :pr:`800` - by :user:`gaborbernat`. - :class:`~filelock.SoftReadWriteLock` waits out a holder's own
stale_thresholdbefore evicting it, keys its singleton on the path its log sits beside, and no longer leaks ledger entries or the holder record of a failed acquire. :pr:`801` - by :user:`gaborbernat`. - :func:`~filelock.lock_descriptor` raises :class:`ValueError` for a blocking
poll_intervalabove :data:`threading.TIMEOUT_MAX` up front, instead of :class:`OverflowError` once the descriptor is contended. :pr:`802` - by :user:`sricharanreddycheruku`. - :class:`~filelock.BaseFileLock` rejects a
boolor string timeout, an out-of-rangemodeand a non-boolblockingset at any time, rejects unknown options on a singleton cache hit, and tracks anon_acquiredreacquire. :pr:`803` - by :user:`gaborbernat`. - :class:`~filelock.StrictSoftFileLock` raises :class:`~filelock.SoftFileLockProtocolError` naming a directory, symlink
or exited soft-lock owner's marker at the lock path, and
lock_path_occupantshows what blocks it. :pr:`804` - by :user:`gaborbernat`. - :class:`~filelock.ReadWriteLock` raises :class:`ValueError` for a WAL-mode database instead of
disk I/O error, and its/dev/fdfallback links beside the database, so a lock off the TMPDIR filesystem no longer fails withEXDEV. :pr:`805` - by :user:`gaborbernat`. - :meth:`ReadWriteLock.release() <filelock.ReadWriteLock.release>` from a thread that holds no read level raises :class:`RuntimeError` instead of ending another thread's read lock and letting a writer in. :pr:`806` - by :user:`gaborbernat`.
- :class:`~filelock.SoftFileLockLifetimeWarning` derives from :class:`FutureWarning` instead of
:class:`DeprecationWarning`, so Python shows it by default outside
__main__. :pr:`807` - by :user:`gaborbernat`. - :class:`~filelock.SoftFileLock` applies an explicit
modepast the umask as :class:`~filelock.UnixFileLock` does, and reads a marker number spelled other than in ASCII digits, or a lease with an empty token, as malformed. :pr:`807` - by :user:`gaborbernat`. - :class:`~filelock.ReadWriteLock` raises :class:`OSError` when its database is unlinked or replaced while an acquisition waits, instead of taking a lock that no later opener sees. :pr:`808` - by :user:`gaborbernat`.
- On a thread-local synchronous lock, :meth:`~filelock.BaseFileLock.release` with
force=Trueand garbage collection release holds exited threads left, and arelease()re-entered from a signal handler closes the descriptor once. :pr:`810` - by :user:`gaborbernat`. - :class:`~filelock.SoftFileLease` records a
lease_durationgiven as a :class:`float` subclass, such as NumPy's, in a form every contender parses, so a live lease is no longer evicted as malformed. :pr:`815` - by :user:`gaborbernat`. - :class:`~filelock.StrictSoftFileLock` raises :class:`~filelock.SoftFileLockProtocolError` for a file at the lock path it cannot parse once it stays unchanged for two seconds, instead of waiting on it forever. :pr:`815` - by :user:`gaborbernat`.
- A lock finalized at interpreter exit no longer hangs when a daemon thread stopped inside filelock's fork bookkeeping. :pr:`815` - by :user:`gaborbernat`.
- Setting :attr:`BaseFileLock.timeout <filelock.BaseFileLock.timeout>` from a string emits a :class:`DeprecationWarning`
and from a
boolraises :class:`TypeError`; pass the number of seconds instead. :pr:`815` - by :user:`gaborbernat`. - Every lock raises :class:`ValueError` for a timeout too large for a :class:`float`, and a singleton accepts a timeout
that waits as long as the cached one, such as
inffor-1. :pr:`815` - by :user:`gaborbernat`. - On macOS, :class:`~filelock.ReadWriteLock` connects through a private hard link, so cycling a lock beside a holder no longer adds an open descriptor per connection. :pr:`815` - by :user:`gaborbernat`.
- :class:`~filelock.SoftFileLock` and :class:`~filelock.SoftFileLease` re-check a stale marker right before breaking it, so a marker recreated since the check is no longer moved aside for a third contender to take the path. :pr:`815` - by :user:`gaborbernat`.
- An acquire a signal handler starts while its thread is still acquiring the same lock raises :class:`RuntimeError`, where it used to hang that thread or leave the lock held after the outer release. :pr:`815` - by :user:`gaborbernat`.
- A :class:`~filelock.BaseAsyncFileLock` singleton the garbage collector finalizes leaves the singleton cache first, so a new lock on the path waits for its release instead of re-entering a hold that release then drops. :pr:`815` - by :user:`gaborbernat`.
- A finalized thread-local :class:`~filelock.BaseAsyncFileLock` releases every thread's hold, including one on a daemon thread's event loop at interpreter exit, instead of leaving it held. :pr:`815` - by :user:`gaborbernat`.
- A soft lock in the host's PID namespace no longer breaks a live marker written from a container sharing the hostname while the kernel shows its owner running in another namespace under the recorded PID and start time. :pr:`815` - by :user:`gaborbernat`.
- :class:`~filelock.SoftFileLock` and its marker and lease variants no longer leave their marker behind when a signal handler interrupts a release; the retried release, or the next acquire on Windows, removes it. :pr:`815` - by :user:`gaborbernat`.
- :class:`~filelock.SoftReadWriteLock` raises :class:`ValueError` for a
heartbeat_intervalabove :data:`threading.TIMEOUT_MAX`, which killed its heartbeat thread, and an interrupted release still removes its record. :pr:`815` - by :user:`gaborbernat`. - :class:`~filelock.AsyncReadWriteLock` releases only its own hold on a singleton it shares with synchronous users, where it used to end their read transaction too. :pr:`815` - by :user:`gaborbernat`.
- The documentation's canonical link,
og:urland sitemap entries point at the versioned page on Read the Docs instead of a domain-root URL that returns 404. :pr:`813` - by :user:`gaborbernat`.
- Fix read-lock acquisition on SQLite versions older than 3.33.0 by using
sqlite_masterfor the schema probe. :pr:`769` - by :user:`Vikram12301`.
ReadWriteLockandAsyncReadWriteLockuse a validated private hard link when/dev/fdhas no entry for the database descriptor, supporting NetBSD's static descriptor directory beyond descriptor 63. The temporary location must share a filesystem with the database. The symlink refusal test accepts NetBSD's error wording - by :user:`gaborbernat`.
- Reusing a singleton
AsyncFileLockwith anotherloop,executororrun_in_executor, or a singletonSoftFileLeasewith anotherlease_duration,heartbeat_intervaloron_compromise, now raisesValueErrorinstead of returning the lock with its original options. :pr:`765` - by :user:`kokotatan`.
ReadWriteLockandAsyncReadWriteLockclose the descriptor that checks the database path once SQLite has connected, so on PyPy a dropped lock leaves no descriptor open until garbage collection runs. :pr:`763` - by :user:`gaborbernat`.
ReadWriteLockandAsyncReadWriteLockrefuse a symlink at the database path instead of following it, so a user who can create names in a shared lock directory cannot point the lock at another file (GHSA-j8f7-rjxc-mr56) - by :user:`gaborbernat`.
ReadWriteLock.release()andSoftReadWriteLock.release()from a thread that does not hold the write lock now raiseRuntimeErrorinstead of dropping the holder's lock and letting a second writer in. :pr:`761` - by :user:`feiiiiii5`.
- File locks now raise
ValueErrorat construction whenmodedenies the owner read or write, such asmode=0o444, instead of failing on a later acquire and staying broken until someone deletes the lock file. :pr:`760` - by :user:`gaborbernat`.
- Reject negative blocking timeouts other than
-1before reentrantReadWriteLockandSoftReadWriteLockacquisition. Preserve unlimited waits and nonblocking acquisition. :pr:`756` - by :user:`feiiiiii5`.
- Fix
MarkerSoftFileLockacquisition and prevent contenders from evicting live protocol-2 owners after two seconds. Reclaim recognized records after owner death; preserve unknown contracts. :pr:`751` - by :user:`DawnofGenX`. - Honor instance
timeoutandblockingsettings in sync and asyncReadWriteLockacquisition, including waits between tasks on one instance. Preserve explicit per-call overrides. :pr:`752` - by :user:`DawnofGenX`. - Skip access-denial checks when the process can read mode-
0o000files. Keep mode-bit checks enabled for privileged processes on filesystems that support POSIX permissions. :pr:`753` - by :user:`pasmud`. - Skip vanished
StrictSoftFileLockclaims after a read-permission retry expires. Recheck the directory before raising a protocol error so concurrent removal does not turn a stale claim listing into an acquisition failure. :pr:`754` - by :user:`januththedev`. - Reject negative timeouts other than
-1in blockingAsyncReadWriteLockandAsyncSoftReadWriteLockacquisitions. Keep-1as an unlimited wait and ignore timeouts whenblocking=False. :pr:`755` - by :user:`pasmud`.
- Hostnames that still differ after their first 253 escaped characters now publish distinct owners, so a soft lock no longer takes another such host's live holder for its own and reclaims its marker. :pr:`748` - by :user:`feiiiiii5`.
- Importing filelock on CPython 3.10 or 3.11 no longer makes new threads fail with
RuntimeError: Cannot install a trace function while another trace function is being installedunder coverage or a debugger. filelock skips its fork-safety audit hook there, so forking from inside a thread's own lock-state transition no longer raises immediately on those versions. :pr:`747` - by :user:`gaborbernat`.
- Concurrent
acquire()andrelease()on athread_local=Falselock no longer leak the OS lock, close a descriptor twice, drop a lease token, or leave a false deadlock after a cross-thread release (:issue:`744`). :pr:`745` - by :user:`gaborbernat`. - :class:`~filelock.AsyncReadWriteLock` and :class:`~filelock.AsyncSoftReadWriteLock` now give each
asynciotask its own hold, so tasks sharing one instance no longer enter the write lock together. :pr:`746` - by :user:`gaborbernat`. - Correct the async cache example to create its data directory and clarify automatic creation of lock-file parent directories. :pr:`740` - by :user:`agammann`.
poll_intervalis now validated at construction, on the setter, and onacquire(): a negative, non-finite, or non-numeric value raises :class:`ValueError`/:class:`TypeError` immediately instead of failing insidetime.sleep. :pr:`739` - by :user:`Pitchfork-and-Torch`.
- :class:`~filelock.SoftReadWriteLock` exposes :attr:`~filelock.SoftReadWriteLock.generation` as a fencing token for the
protected resource and reports a lost hold through
on_compromiseand :attr:`~filelock.SoftReadWriteLock.compromise`. :pr:`738` - by :user:`gaborbernat`.
- The :class:`~filelock.SoftReadWriteLock` on-disk protocol is a generation log under
<path>.rw, and a process running an earlier release does not see it: an old and a new participant on one lock path do not exclude each other. Stop every participant, upgrade them all, then restart them; the new code ignores leftover.state,.writeand.readers/files, and you can delete them. The filesystem must provide no-replace hard links, as it must for :class:`~filelock.StrictSoftFileLock`, so a runtime withoutos.linkraises :class:`~filelock.SoftFileLockProtocolError` on acquire. Constructing a singleton again with a differenton_compromise, or withpoll_intervalat or abovestale_threshold, now raises :class:`ValueError`. :pr:`738` - by :user:`gaborbernat`. - :class:`~filelock.SoftReadWriteLock` no longer deadlocks when a holder dies on another host mid-transition, and
release()no longer waits on a mutex a dead host left behind. The state mutex is gone. Each transition is one atomic snapshot commit, and liveness is a heartbeat nonce read on the observer's own clock rather than anmtimeread against another host's. :pr:`738` - by :user:`gaborbernat`.
- Document that :meth:`~filelock.BaseFileLock.acquire` reads
blocking=Noneas the lock'sblockingattribute and raises :class:`~filelock.Timeout` after one attempt whenblocking=False. :pr:`733` - by :user:`hxperl`.
- Allow acquiring existing lock files that grant write access through group permissions or an ACL even when their owner-write mode bit is unset. :pr:`728` - by :user:`jackwalkerlabs`.
SoftFileLeaseandAsyncSoftFileLeasenow reject a boolean or non-finitelease_duration, which used to publish an owner record their ownownerproperty reads back as malformed. :pr:`723` - by :user:`lprnmns`.- Reject non-finite heartbeat, stale, and polling intervals in
SoftReadWriteLockandAsyncSoftReadWriteLock, including cached singleton construction and overflow in the default stale threshold. :pr:`724` - by :user:`lprnmns`. - Honor acquisition timeouts and
blocking=FalseduringSoftReadWriteLockstate-mutex contention, including failed writer cleanup. Cross-host recovery of an abandoned.statemarker remains unsupported. :pr:`726` - by :user:`Sohel2309`. - Preserve exception notes and custom attributes when copying or pickling
TimeoutandSoftFileLockProtocolError. :pr:`729` - by :user:`jackwalkerlabs`.
SoftFileLease.tokenandAsyncSoftFileLease.tokennow readNoneafter a failed acquisition, so a contender turned away by a live holder no longer reports a token for a claim it never published. :pr:`721` - by :user:`lprnmns`.- Document that
modehas no setter: unlikepoll_interval,timeout,blockingandlifetime, it is fixed at construction andlock.mode = ...raisesAttributeError. :pr:`716` - by :user:`Gares95`.
StrictSoftFileLockalways retries a claim read whose first attempt reports the claim as pending, so a first read that itself outlasts the retry grace no longer fails closed on a claim it could have read. :pr:`705` - by :user:`gaborbernat`.WindowsFileLockwaits out a transientSTATUS_ACCESS_DENIEDfromNtCreateFilefor up to half a second before raisingPermissionError, since a peer unlinking the lock file as it releases can answer that for a moment; a real denial still fails fast. :pr:`705` - by :user:`gaborbernat`.- Every lock class now escapes the hostname it publishes, so a host whose
socket.gethostname()carries a space, a newline or a byte outside UTF-8 no longer writes a marker it reads back as malformed. Such a host used to lose a heldSoftReadWriteLockread slot to a peer and could not take a write slot or aStrictSoftFileLockat all. :pr:`709` - by :user:`dxbjavid`.
- The fork-safety audit hook no longer prints
Exception ignored in audit hookwith aTypeErrorwhen an audit event fires during interpreter shutdown, after CPython has already cleared the module globals. :pr:`703` - by :user:`gaborbernat`.
- A
SoftReadWriteLockorSoftFileLeaseacquire whose heartbeat thread fails to start now unlinks its marker and hands the claim back, instead of leaving an unrefreshed marker a peer takes while the caller believes it still holds the lock. :pr:`691` - by :user:`dxbjavid`. - Canceling an
AsyncSoftReadWriteLockacquire now releases the claim instead of leaking a marker whose heartbeat wedges every contender. :pr:`686` - by :user:`dxbjavid`.
- Declare support for Python 3.15 and run the test suite against it and its free-threaded build, both currently in beta. :pr:`683` - by :user:`gaborbernat`.
SoftReadWriteLockcloses the directory handle it opens to scan for readers as soon as a scan stops early, rather than holding it until the generator is collected. :pr:`685` - by :user:`gaborbernat`.
filelockimports again on runtimes whoseerrnoomitsENOTSUP, such as GraalPy, where importing the package raisedImportError. It probes the code instead, preferringENOTSUP, falling back toEOPNOTSUPPwhere that name is absent, and dropping toENOSYS/EXDEVwhere neither exists. Platforms definingENOTSUPkeep their behavior. :pr:`681` - by :user:`gaborbernat`.
- A
SoftFileLeaseacquired on one thread keeps its claim when another thread fails to acquire the same lease object, so its heartbeat carries on refreshing the marker instead of being torn down and letting a peer take the live claim. :pr:`680` - by :user:`dxbjavid`.
- Support Termux/Android, whose CPython ships without
os.linkand reportssys.platform == "android".import filelockand bothFileLockandSoftFileLocknow work there,StrictSoftFileLockreports its missing hard-link support only when acquired, and process liveness reads/procon Android instead of PID-only checks. :pr:`678` - by :user:`gaborbernat`.
StrictSoftFileLockno longer lets two processes hold the lock at once under heavy contention. A holder now keeps its intent claim for the whole hold, so a contender whose directory scan races the holder's freshly linked claim can no longer miss it and win alongside it. A held lock now exposes both anintentand aheldclaim. :pr:`678` - by :user:`gaborbernat`.
AsyncFileLockandAsyncSoftFileLockno longer raise a deadlockRuntimeErrorwhen a different asyncio task waits for a lock they hold; the check now scopes holders to the owning task, so only a same-task reacquire is refused. :pr:`676` - by :user:`xt-yin`.
- Keep both tables of contents on screen at any browser font size. The widened body column sized itself in
emagainst the reader's font size while the breakpoints that fold the layout resolveemagainst a fixed 16px, so a reader whose default font is larger than 16px had the right-hand table of contents clipped off the edge. The body column now flexes instead, and the right-hand table of contents hides only at the mobile breakpoint. :pr:`673` - by :user:`gaborbernat`. - Color the mermaid diagrams from whichever theme is active. They previously carried a light palette baked into each diagram's source, which stayed light on a dark page. :pr:`674` - by :user:`gaborbernat`.
- Stop :class:`~filelock.SoftFileLease` deleting a live marker whose
modeit does not implement. An unrecognized mode now names its owner instead of reading as malformed, so a record written by a newer filelock survives the grace window rather than being evicted after two seconds. :pr:`672` - by :user:`gaborbernat`. - Stop :class:`~filelock.StrictSoftFileLock` and :class:`~filelock.AsyncStrictSoftFileLock` calling themselves a native
OS lock when they warn that they ignore
lifetime; they now say a strict claim is only ever cleared byforce_break(). :pr:`672` - by :user:`gaborbernat`.
- Cover every lock type in the tutorials and how-to guides, with examples drawn from projects that use filelock, and
color the mermaid diagrams. Correct the claims that
StrictSoftFileLockexposesowner, that :class:`~filelock.SoftFileLock` evicts a strict sentinel, that :class:`~filelock.ReadWriteLock` requires a.dbextension, and that every log record isDEBUG. :pr:`672` - by :user:`gaborbernat`.
StrictSoftFileLockandAsyncStrictSoftFileLockno longer abort acquisition when a peer's claim vanishes as an NFSv3 stale filehandle instead of a clean removal; the reader revalidates and skips it, so strict locks hold mutual exclusion across independent NFSv3 client caches. :pr:`669` - by :user:`gaborbernat`.SoftFileLeasereads a marker whose lease duration isnanorinfas malformed rather than as a valid lease, so such a marker ages out through the grace window instead of raisingLeaseSettingsMismatchon every contender. :pr:`670` - by :user:`dxbjavid`.
- Add
context_error_policyto surface body and release failures as a :exc:`BaseExceptionGroup`. :pr:`618` - by :user:`gaborbernat`. - Add
close_error_policyto control an :func:`os.close` failure after the OS unlock. :pr:`619` - by :user:`gaborbernat`. - Add :func:`~filelock.lock_descriptor` and :func:`~filelock.unlock_descriptor` to lock a caller-owned file descriptor. :pr:`620` - by :user:`gaborbernat`.
- Add
fallback_to_softto fail closed instead of downgrading to :class:`~filelock.SoftFileLock` onENOSYS. :pr:`622` - by :user:`gaborbernat`. - Add
preserve_lock_fileso native locks keep the lock pathname on release. :pr:`624` - by :user:`gaborbernat`. - Add an
on_acquiredhook that runs a callback on the locked descriptor once the lock is held. :pr:`625` - by :user:`gaborbernat`. - Add
StrictSoftFileLock, which treats every marker it did not publish as contention, andSoftFileLease, whose claim expires and whose holder learns throughon_compromisewhen it is lost.SoftFileLock(lifetime=...)now warns and names them. Both publish a recordSoftFileLockevicts, so do not mix contracts on one path. :pr:`658` - by :user:`gaborbernat`. - Add
StrictSoftFileLockandAsyncStrictSoftFileLockwith owner-specific hard-linked claims. Strict mode fails closed on claim damage, exposes each recovery token, and requires an exact claim name for a force break. :pr:`659` - by :user:`gaborbernat`.
- Make native lock release transactional so a failed unlock is retried, not dropped. :pr:`615` - by :user:`gaborbernat`.
- Ignore
lifetimeon native locks with a warning; only :class:`~filelock.SoftFileLock` honors it. :pr:`593` - by :user:`gaborbernat`. - Stop mutating the Unix lock file before :func:`fcntl.flock` is held. :pr:`594` - by :user:`gaborbernat`.
- Evict a non-regular soft lock file without reading it. :pr:`597` - by :user:`dxbjavid`.
- Write a soft lock's holder record atomically so a short write cannot create overlapping holders. :pr:`614` - by :user:`gaborbernat`.
- Open the Windows lock file via
NtCreateFileso a real access denial is raised, not reported as a timeout. :pr:`617` - by :user:`gaborbernat`. - Canonicalize singleton keys so equivalent path spellings share an instance, without following a final symlink. :pr:`621` - by :user:`gaborbernat`.
- Preserve parent lock ownership across
fork(). A child closes an inherited descriptor only while its identity still matches, so it neither unlocks nor unlinks the parent's lock. It clears inherited ownership state and singleton caches, then requires a new lock instance before acquiring. Fork-time construction replaces inherited cache mutexes and omits an instance whose construction crossed into the child from the cache. Iffstat()cannot establish the identity, child cleanup skips the descriptor number because an earlier fork callback may have reused it. Descriptor tracking also covers third-party backends that fail after assigning a descriptor. :pr:`652` - by :user:`gaborbernat`. - Open a SQLite connection per outer acquisition and close it on final release, so a forked child can no longer close
its parent's handle. A child rejects inherited databases until
exec(), and a PyPy child rejects read-write locks once the parent has used SQLite. :pr:`657` - by :user:`gaborbernat`. - Keep executor-backed lock operations alive until they finish when a caller cancels. Serialize acquisitions on the same
async lock so cancellation rollback cannot release a later caller's hold. Roll back acquisitions that finish after
cancellation and surface release failures. SQLite read-write locks keep their state until rollback ends the
transaction; callers can retry cleanup with
release(force=True)or another acquisition. :pr:`652` - by :user:`gaborbernat`. - Reject negative and non-finite
lifetimevalues during lock construction and assignment. :pr:`644` - by :user:`gaborbernat`. - Read the saved Windows process-probe error before deciding that a soft-lock holder has exited. :pr:`645` - by :user:`gaborbernat`.
- Reject non-default lock options that a narrow subclass constructor cannot honor, and forward all options through subclasses that accept arbitrary keyword arguments. :pr:`646` - by :user:`gaborbernat`.
- Release now removes the path identity that acquisition recorded instead of resolving a symlinked parent again. When acquisition raises, its rollback no longer deletes the holder's deadlock record. :pr:`647` - by :user:`gaborbernat`.
- Remove the body error from implicit context on the release error before adding both errors to an exception group. :pr:`648` - by :user:`gaborbernat`.
- Relinquish a soft lock's descriptor before one close attempt so a later release cannot close a reused descriptor
number, and honor
close_error_policywhile still attempting marker cleanup. :pr:`649` - by :user:`gaborbernat`. - Raise
OSError(errno.ENOSYS)from descriptor locks whenfcntlis unavailable, and reject invalid blocking poll intervals before attempting a lock. :pr:`650` - by :user:`gaborbernat`. SoftFileLockandSoftFileLeaserecord the holder's process start time on every platform and reclaim a stale marker only when the recorded owner is provably gone. A reused PID on Unix no longer breaks a live lock or wedges acquisition, matching the recycled-PID detection Windows already had. :pr:`660` - by :user:`gaborbernat`.SoftReadWriteLockandSoftFileLeaseride out a transient filesystem error during a heartbeat instead of dropping the lock or reporting a false compromise, and report a lost claim only once refresh cannot recover before the lease would lapse.SoftFileLeasealso reclaims a malformed or partial marker that used to block every contender, and a Linux marker distinguishes a PID reused across a reboot. :pr:`661` - by :user:`gaborbernat`.BaseFileLock.__del__suppresses a release error rather than raising it during garbage collection, where it surfaced as an unraisable-exception warning attributed to unrelated code. :pr:`665` - by :user:`gaborbernat`.
- Correct the Unix lock-file cleanup and :func:`fcntl.flock` documentation. :pr:`623` - by :user:`gaborbernat`.
- Refresh the documentation to the current code: a new trust-boundaries and ownership-scope section (same-UID boundary,
advisory native locks, strict claims and lease fencing, a filesystem support matrix, migration off timed stale
breaking), the lock-selection flowchart and comparison tables extended with
StrictSoftFileLockandSoftFileLease, and the cross-platform process start token replacing the Windows-only description throughout. :pr:`663` - by :user:`gaborbernat`. - The filesystem support matrix records mutual exclusion measured across two independent client caches in CI: NFS (v4 and v3) for the native, soft, and strict locks, and SMB for the native and soft locks. :pr:`665` - by :user:`gaborbernat`.
- Bind the Windows reparse-point check to the locked handle to close a symlink-swap race. :pr:`596` - by :user:`gaborbernat`.
- Evict a non-regular write marker without reading it :pr:`588` - by :user:`gaborbernat`.
- Detect cross-instance reentrant deadlocks before the poll loop https://github.com/tox-dev/filelock/commit/616400e382cdc9cc8c95823014e4d2d61a70095c - by :user:`HrachShah`
- Serialize singleton construction in
FileLockMeta:pr:`581` - by :user:`dxbjavid`
- Use a private break name in
break_lock_file:pr:`576` - by :user:`dxbjavid`
- Reject negative, non-numeric, and bool values at the setter https://github.com/tox-dev/filelock/commit/be562277636140c26578a98a2a487fdb6f446ee6 - by :user:`HrachShah`
- Roll back a read acquire's open transaction when its SELECT fails :pr:`575` - by :user:`dxbjavid`
- Keep Unix lock files after release :pr:`577` - by :user:`itscloud0`
- Don't complete a writer acquire on a peer's reclaimed marker :pr:`571` - by :user:`dxbjavid`
- Don't follow symlinks in
raise_on_not_writable_file:pr:`567` - by :user:`dxbjavid` - Only unlink the writer marker on release if it is still ours :pr:`566` - by :user:`dxbjavid`
- Don't follow symlinks when refreshing soft read/write lock markers :pr:`565` - by :user:`dxbjavid`
- Serialize read/write release rollback against a concurrent acquire :pr:`563` - by :user:`dxbjavid`
- Keep the read/write heartbeat alive on a transient touch error :pr:`562` - by :user:`dxbjavid`
- Verify inode in
break_lock_filebefore unlinking a stale lock :pr:`561` - by :user:`dxbjavid`
- Validate pid range in
_parse_lock_holder:pr:`556` - by :user:`dxbjavid`
- Check hostname in
is_lock_held_by_us:pr:`553` - by :user:`dxbjavid` - Recover malformed soft-lock markers without breaking a live lock. :pr:`551` - by :user:`gaborbernat`.
- Open marker reads non-blocking to refuse attacker-placed fifo :pr:`549` - by :user:`dxbjavid`
- Clarify per-thread scope of :class:`~filelock.FileLock` configuration :pr:`543` - by :user:`Gares95`
- Fix API docs of :meth:`~filelock.BaseFileLock.release` :pr:`540` - by :user:`MrAnno`
- Refuse symlinks when reading a soft lock file. :pr:`548` - by :user:`dxbjavid`.
- Detect stale soft locks on Windows. :pr:`534` - by :user:`gaborbernat`.
- Use one executor thread for async lock operations to keep acquisition and release ordered. :pr:`533` - by :user:`gaborbernat`.
- Inspect a soft lock's owner PID and break stale locks. :pr:`524` - by :user:`gaborbernat`.
- Add :class:`~filelock.SoftReadWriteLock` for NFS and HPC clusters. :pr:`528` - by :user:`gaborbernat`.
- Handle
__exit__and event-loop shutdown for :class:`~filelock.BaseAsyncFileLock`. :pr:`518` - by :user:`naarob`.
- Suppress
EIOwhen closing a Unix lock on a Docker bind mount. :pr:`513` - by :user:`gaborbernat`.
- Restore best-effort lock file cleanup on Windows. :pr:`511` - by :user:`gaborbernat`.
- Add the project logo to the documentation. :pr:`507` - by :user:`gaborbernat`.
- Add :class:`~filelock.AsyncReadWriteLock`. :pr:`506` - by :user:`gaborbernat`.
- Suppress :class:`ValueError` while checking a corrupt stale-lock marker. :pr:`496` - by :user:`bysiber`
- Fix nonblocking transaction-lock acquisition with a timeout. :pr:`498` - by :user:`gaborbernat`
- Handle an
ENOENTrace while acquiring a lock on FUSE or NFS. :pr:`495` - by :user:`gaborbernat`.
- Close SQLite cursors and avoid a :class:`~filelock.SoftFileLock` race on Windows. :pr:`491` - by :user:`gaborbernat`.
- Organize the documentation into tutorials, how-to guides, reference, and explanations. :pr:`489` - by :user:`gaborbernat`.
- Fix a soft-lock deadlock on Windows. :pr:`488` - by :user:`gaborbernat`.
- Add a
lifetimeparameter for lock expiration (:issue:`68`). :pr:`486` - by :user:`gaborbernat`. - Add
cancel_checkto :meth:`~filelock.BaseFileLock.acquire` (:issue:`309`). :pr:`487` - by :user:`gaborbernat`. - Honor POSIX default ACLs when creating a lock file (:issue:`378`). :pr:`483` - by :user:`gaborbernat`.
- Add
poll_intervalto the lock constructor. :pr:`482` - by :user:`gaborbernat`.
- Detect a same-thread self-deadlock. :pr:`481` - by :user:`gaborbernat`.
- Fix a lock file race between threads on Windows. :pr:`484` - by :user:`gaborbernat`.
- Fall back to :class:`~filelock.SoftFileLock` when native locking fails with
ENOSYS. :pr:`480` - by :user:`gaborbernat`.
- Change the project license from Unlicense to MIT. :pr:`479` - by :user:`gaborbernat`.
- List fasteners among the similar libraries in the documentation. :pr:`478` - by :user:`gaborbernat`.
- Detect and break stale soft locks. :pr:`476` - by :user:`gaborbernat`.
- Disable stale-lock detection on Windows until its implementation is safe. :pr:`477` - by :user:`gaborbernat`.
- Handle :exc:`ImportError` when the :mod:`sqlite3` C library is unavailable. :pr:`475` - by :user:`gaborbernat`.
- Import :class:`~filelock.ReadWriteLock` when :mod:`sqlite3` is unavailable. :pr:`473` - by :user:`bayandin`.
- Add a SQLite-backed :class:`~filelock.ReadWriteLock`. :pr:`399` - by :user:`leventov`
- Allow Unix lock files to be removed after release. :pr:`408` - by :user:`sbc100`
- Fix TOCTOU symlink vulnerability in :class:`~filelock.SoftFileLock` :pr:`465` - by :user:`gaborbernat`.
- Support Unix systems without :data:`os.O_NOFOLLOW` :pr:`463` - by :user:`mwilliamson`.
- Fix TOCTOU symlink vulnerability in lock file creation :pr:`461` - by :user:`gaborbernat`.
- Add Python 3.14 support, drop 3.9 :pr:`448` - by :user:`gaborbernat`.
- Add support for Python 3.14 :pr:`432` - by :user:`gaborbernat`.
- Support :mod:`fcntl` check on Emscripten :pr:`398` - by :user:`juntyr`.
- Indicate that locks are exclusive/write locks :pr:`394` - by :user:`bicarlsen`.
- Drop Python 3.8 support :pr:`388`.
- Add Python 3.13 to CI :pr:`359` - by :user:`gaborbernat`.
- Pass
file_lockas positional argument :pr:`347` - by :user:`kwist-sgr`.
- Fix
TypeError: _CountedFileLock.__init__() got an unexpected keyword argument:pr:`345` - by :user:`kwist-sgr`.
- Use a metaclass to implement the singleton pattern :pr:`340` - by :user:`kwist-sgr`.
- Restore
__init__method; more robust initialization for singleton locks :pr:`338` - by :user:`ethanbb`.
- Add asyncio support :pr:`332` - by :user:`Ovizro`.
- Don't re-initialize :class:`~filelock.BaseFileLock` when returning existing singleton instance :pr:`334` - by :user:`ethanbb`.
- Add
blockingparameter on lock constructor :pr:`325` - by :user:`iamkhav`.
- Raise error on incompatible singleton
timeoutandmodearguments :pr:`320` - by :user:`nefrob`.
- Make singleton class instance dict unique per subclass :pr:`318` - by :user:`nefrob`.
- Fix permission denied error when lock file is placed in
/tmp:pr:`317` - by :user:`kota-iizuka`.
- Allow users to subclass :class:`~filelock.FileLock` with custom keyword arguments :pr:`284` - by :user:`hmaarrfk`.
- Support reentrant locking on lock file path via optional
is_singletoninstance :pr:`283` - by :user:`nefrob`.
- Change
typing-extensionsto be installed only with the[typing]extra :pr:`276` - by :user:`asottile`.
- Create parent directories if necessary :pr:`254` - by :user:`gerlero`.
- Restore
if TYPE_CHECKINGsyntax for :class:`~filelock.FileLock` definition :pr:`245` - by :user:`dlax`.
- Add Python 3.12 support :pr:`237` - by :user:`gaborbernat`.
- Allow callers to disable thread-local lock state at construction; it remains enabled by default. :pr:`232` - by :user:`csm10495`.
- Fix a lock hang on Windows. :pr:`231` - by :user:`TheMatt2`.
- Keep lock state local to each thread. :pr:`219` - by :user:`csm10495`.
- Use :func:`os.fchmod` to avoid a :func:`os.chmod` failure on PyPy via Anaconda. :pr:`214` - by :user:`jfennick`.
- Raise unexpected file-opening errors from :class:`~filelock.SoftFileLock` instead of repeatedly waiting for a lock that cannot be acquired. :pr:`213` - by :user:`jahrules` and :user:`gaborbernat`.
- Raise :class:`NotImplementedError` when a Unix filesystem does not support
flockinstead of waiting indefinitely. :pr:`212` - by :user:`jahrules`.
- Apply the requested file mode when creating a Unix lock file, including when the file cannot later be changed with
chmod. :pr:`211` - by :user:`jahrules`.
- Fix permission issue - by :user:`jahrules`.
- Bug fix for using filelock with threaded programs causing undesired file permissions - by :user:`jahrules`.
- Handle pickle for :class:`~filelock.Timeout` :pr:`203` - by :user:`TheMatt2`.
- Add support for explicit file modes for lockfiles :pr:`192` - by :user:`jahrules`.
- Use :func:`time.perf_counter` instead of :func:`time.monotonic` to calculate timeouts. :pr:`194` - by :user:`zpz`.
- Update the published license classifier to Unlicense. :pr:`180` - by :user:`jond01`
- Make :class:`~filelock.FileLock` valid in mypy type annotations. :pr:`177` - by :user:`gaborbernat`.
- Add Python 3.11 support. :pr:`158` - by :user:`gaborbernat`.
- State timeout units in the API docstrings. :pr:`148` - by :user:`jnordberg`.
- Point README documentation links to the site index - by :user:`gaborbernat`.
- Allow a lock attempt to return immediately when the lock cannot be acquired. :pr:`142` - by :user:`myheroyuki`.
- Fix pylint warning "Abstract class :class:`~filelock.WindowsFileLock` with abstract methods instantiated" :pr:`135` - by :user:`vonschultz`
- Fix pylint warning "Abstract class :class:`~filelock.UnixFileLock` with abstract methods instantiated" :pr:`135` - by :user:`vonschultz`
- Use a monotonic clock for timeouts so wall-clock changes do not change their duration. :pr:`136` - by :user:`avian2`.
- Allow a lock to be used as a context decorator. :pr:`128` - by Hirsch Alter.
- Drop Python 3.6 support. :pr:`125` - by :user:`gaborbernat`.
- Point argument deprecation warnings at the caller by setting
stacklevel. :pr:`121` - by :user:`XuehaiPan`.
- Add correct spelling of poll interval parameter for :meth:`~filelock.BaseFileLock.acquire` method, raise deprecation warning when using the misspelled form :pr:`119` - by :user:`XuehaiPan`.
- Accept :class:`pathlib.Path` and :class:`pathlib.PurePath` in the :class:`~filelock.FileLock` constructor. :pr:`110` - by :user:`f-koehler`.
- Leave the log level of the
filelocklogger as not set (previously was set to warning) :pr:`108` - by :user:`gaborbernat`
- Add changelog to the documentation :pr:`108` - by :user:`gaborbernat`
- Drop Python 2.7 and 3.5 support. :pr:`100` - by :user:`gaborbernat`.
- Add type annotations. :pr:`100` - by :user:`gaborbernat`.
- Document asyncio support - by :user:`gaborbernat`
- Changed logger name from
filelock._apitofilelock:pr:`97` - by :user:`hkennyv`
- Add a tutorial covering lock acquisition, timeouts, and recursive use - by :user:`gaborbernat`.
- Move lock acquire/release log from INFO to DEBUG :pr:`95` - by :user:`gaborbernat`
- Raise when trying to acquire in R/O or missing folder :pr:`96` - by :user:`gaborbernat`
- Fix the LICENSE link. :pr:`63` - by :user:`sharkwouter`.
- Update links for the project's move to tox-dev. :pr:`88` - by :user:`hugovk`.
- Fix package setup on Python 2 - by Benedikt Schmitt.
- Correct the timeout documentation: zero means no wait, while a negative value waits indefinitely. :issue:`49` - by Benedikt Schmitt; reported by :user:`AnkurTank`.
- Fix package upload to PyPI by keeping the license summary on one line - by Benedikt Schmitt.
- Update the published PyPI classifiers - by :user:`hugovk`.
- Fix README rendering on PyPI - by :user:`adamchainz`.
- Fix a memory leak when acquiring locks on Python 2. :issue:`37` - by Benedikt Schmitt.
- Render the animated README example through a raw image URL on PyPI - by Benedikt Schmitt.
- Keep the Unix lock file after release to avoid a race between processes. :issue:`31` - by Benedikt Schmitt.
- Add navigation to the README - by Benedikt Schmitt.
- Clarify when to use a separate lock file in the documentation. :issue:`22` - by Benedikt Schmitt.
- Remove the Unix lock file after :meth:`~filelock.BaseFileLock.release` - by :user:`spokorski`.
- Reraise lock errors correctly on Python 3 - by Benedikt Schmitt.
- Acquire the logger only when first needed. :issue:`24` - by Benedikt Schmitt.
- Add official Python 2 support. :issue:`20` - by Benedikt Schmitt.
- Add example :pr:`16` - by :user:`pypingou`.
- Update change order of the examples (:pr:`16`) - by :user:`pypingou`.
- Explain why the protected file needs a separate lock path. :issue:`19` - by Benedikt Schmitt.
- Correct the Read the Docs URL - by Benedikt Schmitt.
- Add logging for lock operations - by :user:`expobrain`.
- Keep the README and license out of the installed environment root while including them in the source archive. :issue:`14` - by Benedikt Schmitt.
- Clear the lock descriptor before unlocking on Unix and Windows, avoiding a repeated release. - by :user:`cottsay`.
- Keep the lock file after release - by :user:`kramarz`.
- Export :class:`~filelock.BaseFileLock` as a public class - by Benedikt Schmitt.
- Show the complete public API in the reference page - by Benedikt Schmitt.
- Export the platform-specific lock classes consistently through
__all__- by Benedikt Schmitt.
- Treat Windows lock contention as a timeout instead of raising
IOError. :issue:`5` - by Benedikt Schmitt. - Avoid an extra acquisition for
with lock.acquire(timeout=...), so one release frees the lock. :issue:`3` - by Benedikt Schmitt.
- Add a documentation site with recursive locking examples and an API reference - by Benedikt Schmitt.
- Allow a default timeout at lock construction. :issue:`2` - by Benedikt Schmitt.
- Handle an exception while acquiring a lock - by Benedikt Schmitt.
- Do not time out when the same lock object already holds the lock - by Benedikt Schmitt.
- Return immediately after a successful first acquire instead of waiting one poll interval. :issue:`1` - by Benedikt Schmitt.
- Add a lock counter so the same lock object can acquire recursively - by Benedikt Schmitt.
- Include the renamed README and license files in the source distribution - by Benedikt Schmitt.
- Publish the README and license as reStructuredText so package metadata can render them - by Benedikt Schmitt.
- Add file locks for Unix and Windows - by Benedikt Schmitt.