HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/tempora/__pycache__/timing.cpython-310.pyc
o

�N�g6�@s|ddlZddlZddlZddlZddlZddlZddlZGdd�d�Z	Gdd�d�Z
Gdd�de	�ZGdd	�d	ejj
�ZdS)
�Nc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�	Stopwatcha�
    A simple stopwatch which starts automatically.

    >>> w = Stopwatch()
    >>> _1_sec = datetime.timedelta(seconds=1)
    >>> w.split() < _1_sec
    True
    >>> import time
    >>> time.sleep(1.0)
    >>> w.split() >= _1_sec
    True
    >>> w.stop() >= _1_sec
    True
    >>> w.reset()
    >>> w.start()
    >>> w.split() < _1_sec
    True

    It should be possible to launch the Stopwatch in a context:

    >>> with Stopwatch() as watch:
    ...     assert isinstance(watch.split(), datetime.timedelta)

    In that case, the watch is stopped when the context is exited,
    so to read the elapsed time::

    >>> watch.elapsed
    datetime.timedelta(...)
    >>> watch.elapsed.seconds
    0
    cCs|��|��dS�N)�reset�start��self�r�B/opt/saltstack/salt/lib/python3.10/site-packages/tempora/timing.py�__init__,szStopwatch.__init__cCs@t�d�|_t�t��|`Wd�dS1swYdS�Nr)�datetime�	timedelta�elapsed�
contextlib�suppress�AttributeError�
start_timerrrr	r0s"�zStopwatch.resetcCstj��|_dSr)r�utcnowrrrrr	r5�zStopwatch.startcCs(tj��}|j||j7_|`|jSr)rrrr)rZ	stop_timerrr	�stop8s
zStopwatch.stopcCstj��|j}|j|Sr)rrrr)rZlocal_durationrrr	�split>s
zStopwatch.splitcCs|��|Sr)rrrrr	�	__enter__CszStopwatch.__enter__cCs|��dSr)r)r�exc_type�	exc_value�	tracebackrrr	�__exit__GszStopwatch.__exit__N)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrrr	rs rc@s$eZdZdZdd�Zdd�ZeZdS)�IntervalGovernorz�
    Decorate a function to only allow it to be called once per
    min_interval. Otherwise, it returns None.

    >>> gov = IntervalGovernor(30)
    >>> gov.min_interval.total_seconds()
    30.0
    cCs(t|tj�rtj|d�}||_d|_dS)N)�seconds)�
isinstance�numbers�Numberrr
�min_interval�	last_call)rr%rrr	r
Us
zIntervalGovernor.__init__cst�����fdd��}|S)Ncs6�jp�j���jk}|rt��_�|i|��SdSr)r&rr%r)�args�kwargsZallow��funcrrr	�wrapper\s
�z*IntervalGovernor.decorate.<locals>.wrapper)�	functools�wraps)rr*r+rr)r	�decorate[szIntervalGovernor.decorateN)rrrrr
r.�__call__rrrr	r Ks
	
r cs<eZdZdZed�f�fdd�	Zedd��Zdd�Z�Z	S)	�Timerz�
    Watch for a target elapsed time.

    >>> t = Timer(0.1)
    >>> t.expired()
    False
    >>> __import__('time').sleep(0.15)
    >>> t.expired()
    True
    �Infcs|�|�|_tt|���dSr)�_accept�target�superr0r
)rr3��	__class__rr	r
tszTimer.__init__cCs(t|tj�r
|��}|durtd�}|S)u�
        Accept None or ∞ or datetime or numeric for target

        >>> Timer._accept(datetime.timedelta(seconds=30))
        30.0
        >>> Timer._accept(None)
        inf
        Nr1)r"rr
�
total_seconds�float)r3rrr	r2xs

z
Timer._acceptcCs|����|jkSr)rr7r3rrrr	�expired��z
Timer.expired)
rrrrr8r
�staticmethodr2r9�
__classcell__rrr5r	r0hs
r0c@sfeZdZdZdZdZ	dZ	ejj	dde
d�dfdd��Zdd�Zd	d
�Z
dd�Zd
d�Zdd�ZdS)�BackoffDelaya�
    Exponential backoff delay.

    Useful for defining delays between retries. Consider for use
    with ``jaraco.functools.retry_call`` as the cleanup.

    Default behavior has no effect; a delay or jitter must
    be supplied for the call to be non-degenerate.

    >>> bd = BackoffDelay()
    >>> bd()
    >>> bd()

    The following instance will delay 10ms for the first call,
    20ms for the second, etc.

    >>> bd = BackoffDelay(delay=0.01, factor=2)
    >>> bd()
    >>> bd()

    Inspect and adjust the state of the delay anytime.

    >>> bd.delay
    0.04
    >>> bd.delay = 0.01

    Set limit to prevent the delay from exceeding bounds.

    >>> bd = BackoffDelay(delay=0.01, factor=2, limit=0.015)
    >>> bd()
    >>> bd.delay
    0.015

    To reset the backoff, simply call ``.reset()``:

    >>> bd.reset()
    >>> bd.delay
    0.01

    Iterate on the object to retrieve/advance the delay values.

    >>> next(bd)
    0.01
    >>> next(bd)
    0.015
    >>> import itertools
    >>> tuple(itertools.islice(bd, 3))
    (0.015, 0.015, 0.015)

    Limit may be a callable taking a number and returning
    the limited number.

    >>> at_least_one = lambda n: max(n, 1)
    >>> bd = BackoffDelay(delay=0.01, factor=2, limit=at_least_one)
    >>> next(bd)
    0.01
    >>> next(bd)
    1

    Pass a jitter to add or subtract seconds to the delay.

    >>> bd = BackoffDelay(jitter=0.01)
    >>> next(bd)
    0
    >>> next(bd)
    0.01

    Jitter may be a callable. To supply a non-deterministic jitter
    between -0.5 and 0.5, consider:

    >>> import random
    >>> jitter=functools.partial(random.uniform, -0.5, 0.5)
    >>> bd = BackoffDelay(jitter=jitter)
    >>> next(bd)
    0
    >>> 0 <= next(bd) <= 0.5
    True
    r��infcsT||_||_t|tj�r|��fdd�}||_t|tj�r%|��fdd�}||_dS)Ncstdt�|��Sr)�max�min)�n)�limit_rr	�limit�rz$BackoffDelay.__init__.<locals>.limitcs�Srrr)�jitter_rr	�jitter��z%BackoffDelay.__init__.<locals>.jitter)�delay�factorr"r#r$rDrF)rrHrIrDrFr)rErCr	r
�s
zBackoffDelay.__init__cCst�t|��dSr)�time�sleep�nextrrrr	r/�r:zBackoffDelay.__call__cCs|j}|��|Sr)rH�bump)rrHrrr	�__next__�szBackoffDelay.__next__cCs|Srrrrrr	�__iter__rGzBackoffDelay.__iter__cCs |�|j|j|���|_dSr)rDrHrIrFrrrr	rMs zBackoffDelay.bumpcCs|j}|j|ji|j��dSr)Z_saved___init__r
r'r()rZsavedrrr	rszBackoffDelay.resetN)rrrrrHrIrF�jaracor,Zsave_method_argsr8r
r/rNrOrMrrrrr	r=�sOr=)rr,r#rJ�collections.abc�collectionsrZjaraco.functoolsrPrr r0�abc�Iteratorr=rrrr	�<module>s@'