Files
intellecton/venv/lib/python3.12/site-packages/filelock/__pycache__/asyncio.cpython-312.pyc
T

172 lines
17 KiB
Plaintext
Raw Normal View History

Ë
jÜ8ãó,dZddlmZddlZddlZddlZddlZddlZddlm Z ddl
m Z ddl m
Z
ddlmZmZmZmZdd lmZmZmZmZdd
lmZdd lmZdd lmZdd
lmZer2ddl Z ddl!m"Z"ddl#m$Z$ddl%m&Z&e jNdk\rddlm(Z(nddl)m(Z(ejTd«Z+e Gdde««Z,Gdde,e
«Z-Gdd«Z.edd¬«Z/Gdde«Z0Gddee0¬ «Z1Gd!„d"ee1«Z2Gd#„d$ee1«Z3Gd%„d&ee1«Z4gd'¢Z5y)(z1An asyncio-based implementation of the file lock.é)Ú annotationsN)Ú dataclass)Úiscoroutinefunction)Úlocal)Ú
TYPE_CHECKINGÚAnyÚNoReturnÚTypeVaré)Ú_UNSET_FILE_MODEÚ BaseFileLockÚFileLockContextÚ FileLockMeta)ÚTimeout)Ú SoftFileLock)Ú UnixFileLock)ÚWindowsFileLock)ÚCallable)Úfutures)Ú
TracebackType)éé )ÚSelfÚfilelockcó<eZdZUdZdZded<dZded<dZded <y)
ÚAsyncFileLockContextzGA dataclass which holds the context for a ``BaseAsyncFileLock`` object.TÚboolÚrun_in_executorNúfutures.Executor | NoneÚexecutorú asyncio.AbstractEventLoop | NoneÚloop)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚ__annotations__r r"©óúS/home/antigravity/intellecton/venv/lib/python3.12/site-packages/filelock/asyncio.pyrr$s+á!€O ð)-€HÐ.2€DÐ
1r)rcóeZdZdZy)ÚAsyncThreadLocalFileContextz8A thread local version of the ``FileLockContext`` class.N©r#r$r%r&r(r)r*r,r,2sÚBr)r,có8eZdZdZddZddZ ddZy) ÚAsyncAcquireReturnProxyzDA context-aware object that will release the lock file when exiting.có||_y©Úlock)Úselfr3s r*Ú__init__z AsyncAcquireReturnProxy.__init__9s ؈ r)cƒó"K|jS­wr1r2©r4s r*Ú
__aenter__z"AsyncAcquireReturnProxy.__aenter__<sèø€Øy‰yÐùs
cƒóTK|jj«ƒd{y7Œ­wr1)r3Úrelease©r4Úexc_typeÚ exc_valueÚ tracebacks r*Ú __aexit__z!AsyncAcquireReturnProxy.__aexit__?sèø€ð i‰i×ÑÓ!ús ( &¡(N)r3ÚBaseAsyncFileLockÚreturnÚNone)rAr@©r<útype[BaseException] | Noner=úBaseException | Noner>zTracebackType | NonerArB)r#r$r%r&r5r8r?r(r)r*r/r/6s:Ùóð
ô "r)r/Ú_ATr@)Úboundc óleZdZdedfddddddddœ dˆfdZˆxZS) ÚAsyncFileLockMetaéÿÿÿÿFTçš™™™™™©?N©ÚblockingÚ is_singletonÚ
poll_intervalÚlifetimer"rr c
óZ|r|
r
d} t| «t
| ||||||||| |
| ¬« S)Nz:run_in_executor is not supported when thread_local is True) Ú lock_fileÚtimeoutÚmodeÚ thread_localrMrNrOrPr"rr )Ú
ValueErrorÚsuperÚ__call__)ÚclsrRrSrTrUrMrNrOrPr"rr ÚmsgÚ __class__s €r*rXzAsyncFileLockMeta.__call__LsQø€ñ ™OØNˆCܘS“/Ð ‰wÑØØØØØØØð ó 
ð
r))rYz type[_AT]rRústr | os.PathLike[str]rSÚfloatrTÚintrUrrMrrNrrOr]rPú float | Noner"r!rrr rrArF)r#r$r%r rXÚ
__classcell__)r[s@r*rIrIKø„ðØ 
ðØ#Ø!%Ø15Ø $Ø,0ñ
Ø
ð
à
ðð
ðð 
ð
ð 
ðð
ðð
ðð
ðð
ð
ðð
ð
ð
÷
ñ
r)rIc ó>eZdZdZdedfddddddddœ ddZedd „«Zedd
«Zejdd «Zedd «Z
dddd
œ ddZ dddZ ddZ
d dZ d!dZd"dZ d#dZd$dZy)%r@zP
Base class for asynchronous file locks.
.. versionadded:: 3.15.0
rJFTrKNrLc
ó||_||_tj|«|||||| |
| dœ } |rtnt
di| ¤Ž|_y)
Create a new lock object.
:param lock_file: path to the file
:param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in the
acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it to a
negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock.
:param mode: file permissions for the lockfile. When not specified, the OS controls permissions via umask and
default ACLs, preserving POSIX default ACL inheritance in shared directories.
:param thread_local: Whether this object's internal context should be thread local or not. If this is set to
``False`` then the lock will be reentrant across threads.
:param blocking: whether the lock should be blocking or not
:param is_singleton: If this is set to ``True`` then only one instance of this class will be created per lock
file. This is useful if you want to use the lock object for reentrant locking without needing to pass the
same object around.
:param poll_interval: default interval for polling the lock file, in seconds. It will be used as fallback value
in the acquire method, if no poll_interval value (``None``) is given.
:param lifetime: maximum time in seconds a lock can be held before it is considered expired. When set, a waiting
process will break a lock whose file modification time is older than ``lifetime`` seconds. ``None`` (the
default) means locks never expire.
:param loop: The event loop to use. If not specified, the running event loop will be used.
:param run_in_executor: If this is set to ``True`` then the lock will be acquired in an executor.
:param executor: The executor to use. If not specified, the default executor will be used.
) rRrSrTrMrOrPr"rr Nr()Ú_is_thread_localÚ
_is_singletonÚosÚfspathr,rÚ_context)
r4rRrSrTrUrMrNrOrPr"rr Úkwargss
r*r5zBaseAsyncFileLock.__init__usaðP!-ˆÔØÔô
Ÿ 9ÓØØ Ø ØØ ñ
"
ˆð0uÉlÕ/JÔ`tñ/
Øñ/
ˆ
r)có.|jjS)z":returns: whether run in executor.)rgrr7s r*rz!BaseAsyncFileLock.run_in_executor±sð}‰}×,r)có.|jjS)z:returns: the executor.©rgr r7s r*r zBaseAsyncFileLock.executor¶sð}‰}×%r)có&||j_y)zs
Change the executor.
:param futures.Executor | None value: the new executor or ``None``
Nrk)r4Úvalues r*r zBaseAsyncFileLock.executor»sð"'ˆ
Õr)có.|jjS)z:returns: the event loop.)rgr"r7s r*r"zBaseAsyncFileLock.loopÅsð}‰}×!r))rMÚ cancel_checkcƒó|K||jj}||jj}||jj}|jxjdz
c_t |«}|j }tj«} |jsJ|j«tjd||«|j|j«ƒd{|jrtjd||«nZ|j||||||¬«r t!|«d}tj||||«t#j$|«ƒd{ŒÔ t+|¬«S7Œ7Œ#t&$r4t)d|jjdz
«|j_wxYw­w) a„
Try to acquire the file lock.
:param timeout: maximum wait time for acquiring the lock, ``None`` means use the default
:attr:`~BaseFileLock.timeout` is and if ``timeout < 0``, there is no timeout and this method will block
until the lock could be acquired
:param poll_interval: interval of trying to acquire the lock file, ``None`` means use the default
:attr:`~BaseFileLock.poll_interval`
:param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the
first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.
:param cancel_check: a callable returning ``True`` when the acquisition should be canceled. Checked on each poll
iteration. When triggered, raises :class:`~Timeout` just like an expired timeout.
:returns: a context object that will unlock the file when the context is exited
:raises Timeout: if fails to acquire lock within the timeout period
.. code-block:: python
# You can use this method in the context manager (recommended)
with lock.acquire():
pass
# Or use an equivalent try-finally construct:
lock.acquire()
try:
pass
finally:
lock.release()
Nr z#Attempting to acquire lock %s on %szLock %s acquired on %s)rMrorSÚ
start_timez2Lock %s not acquired on %s, waiting %s seconds ...rr2)rgrSrMrOÚ lock_counterÚidrRÚtimeÚ perf_counterÚ is_lockedÚ_try_break_expired_lockÚ_LOGGERÚdebugÚ_run_internal_methodÚ_acquireÚ_check_give_uprÚasyncioÚsleepÚ
BaseExceptionÚmaxr/) r4rSrOrMroÚlock_idÚ
lock_filenamerqrZs r*ÚacquirezBaseAsyncFileLock.acquireÊsèø€ðP ˆ?Ø—m‘m×+ˆGà Ð Ø—}‘}×-ˆHà Ð Ø ŸM™M×7ˆMð
×" T“(ˆØŸˆ
Ü×(ˆ
ð ØØ—~’~Ø×—MMÐ"GÈÐR_Ô×3°D·M±MÓB×—>—MMÐ":¸GÀ]ÔØ×Ø%Ø!-Ø
ô" JÜ
˜c 7¨M¸—mm 2×2ð'ðô '¨DÔ1ð'Cøð3ùÜò Ü),¨Q°·
±
×0JÑ0JÈQÑ0NÓ)OˆDM‰MÔ ð üsDBF<ÂAE<Ã(E8Ã)A<E<Å%E:Å&E<Å+
F<Å8E<Å:E<Å<=F9Æ9F<cƒó’K|jrµ|jxjdzc_|jjdk(s|rzt|«|j}}t
j
d||«|j|j«ƒd{d|j_t
j
d||«yyy7Œ/­w)a
Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file
itself is not automatically deleted.
:param force: If true, the lock counter is ignored and the lock is released in every case.
r rz#Attempting to release lock %s on %sNzLock %s released on %s) rvrgrrrsrRrxryrzÚ_release)r4Úforcerrs r*r:zBaseAsyncFileLock.releaseèø€ð >Š>Ø M‰M× &¨!Ñ }‰}×)¨QÒ.±%Ü)+¨D«°4·>±>˜ä
ÐCÀWÈmÔ×·
±
Ó>×>Ø-.
Ô
Ð6¸ÀÕ
38ð ð?úsBCÂCÂ0CcƒóÞKt|«r|«ƒd{y|jr7tj«j|j|«ƒd{y|«y7ŒP7Œ­wr1)rrr}Úget_running_loopr )r4Úmethods r*rzz&BaseAsyncFileLock._run_internal_method.sQèø€Ü ˜ “(N‰NØ
×
×,×<¸T¿]¹]ÈFÓS× 
øà Sús"A-˜A)™AA-ÁA+ÁA-Á+A-cód}t|«)zTSync context manager entry is not supported because lock acquisition is a coroutine.õdUse `async with` — acquire/release are coroutines and cannot be awaited in a sync context manager.©ÚNotImplementedError)r4rZs r*Ú __enter__zBaseAsyncFileLock.__enter__6sàtˆÜ! &r)cód}t|«)zOSync context manager exit is not supported because lock release is a coroutine.r)r4r<r=r>rZs r*Ú__exit__zBaseAsyncFileLock.__exit__;sðuˆÜ! &r)cƒóBK|j«ƒd{|S7Œ­w)zG
Acquire the lock.
:returns: the lock object