Your IP : 216.73.216.209


Current Path : /lib/python3/dist-packages/fasteners/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/fasteners/__pycache__/_utils.cpython-310.pyc

o

V�EV�@svddlZddlZddlmZdZe�e�Zdd�ZGdd�de	�Z
Gdd	�d	e�ZGd
d�de	�Z
Gdd
�d
e	�ZdS)�N)�	monotonic�cGs|D]
}|dur|SqdS)zEReturns first of values that is *not* None (or None if all are/were).N�)�values�valrr�2/usr/lib/python3/dist-packages/fasteners/_utils.py�pick_first_not_nones
�rc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�	LockStackz�Simple lock stack to get and release many locks.

    An instance of this should **not** be used by many threads at the
    same time, as the stack that is maintained will be corrupted and
    invalid if that is attempted.
    NcCsg|_t|t�|_dS�N)�_stackr�LOG�_logger)�self�loggerrrr�__init__.szLockStack.__init__cCs|��}|r|j�|�|Sr
)�acquirer�append)r�lock�gottenrrr�acquire_lock2szLockStack.acquire_lockcCs|Sr
r�rrrr�	__enter__8szLockStack.__enter__cCsdt|j�}|}|jr0|j��}z|��Wnty&|j�d||�Ynw|d8}|js
dSdS)Nz6Failed releasing lock %s from lock stack with %s locks�)�lenr�pop�release�	Exceptionr
�	exception)r�exc_type�	exc_value�exc_tb�am_left�tot_amrrrr�__exit__;s

���zLockStack.__exit__r
)�__name__�
__module__�__qualname__�__doc__rrrr#rrrrr	&s
r	c@seZdZdZdS)�
RetryAgainz1Exception to signal to retry helper to try again.N)r$r%r&r'rrrrr(Hsr(c@s(eZdZdZejdfdd�Zdd�ZdS)�RetryzA little retry helper object.NcCs"||_d|_||_||_||_dS)Nr)�delay�attempts�	max_delay�
sleep_func�watch)rr*r,r-r.rrrrOs

zRetry.__init__cOs�	|jd7_z||i|��WStyH|j|j}||jkr%|}n|j}td|�}|jdurA|j��}|durA||krA|}|�|�Ynwq)NTr�)r+r(r*r,�maxr.�leftoverr-)r�fn�args�kwargs�maybe_delay�actual_delayr1rrr�__call__Ws"



��zRetry.__call__)r$r%r&r'�time�sleeprr7rrrrr)Ls

�r)c@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�	StopWatchzA really basic stop watch.NcCs||_d|_d|_dSr
)�duration�
started_at�
stopped_at)rr;rrrrms
zStopWatch.__init__cCs"|jdurdStd|j|���S�Nr/)r;r0�elapsedrrrrr1rs
zStopWatch.leftovercCs(|jdur	|j}nt�}td||j�Sr>)r=�nowr0r<)r�end_timerrrr?ws
zStopWatch.elapsedcCs|��|Sr
)�startrrrrr~szStopWatch.__enter__cCst�|_dSr
)r@r=)rrrr rrrr#�szStopWatch.__exit__cCst�|_d|_dSr
)r@r<r=rrrrrB�s
zStopWatch.startcCs|jdurdS|��|jkS)NF)r;r?rrrr�expired�s
zStopWatch.expiredr
)r$r%r&r'rr1r?rr#rBrCrrrrr:js
r:)�loggingr8rr@�BLATHER�	getLoggerr$rr�objectr	rr(r)r:rrrr�<module>s
"