• File: __init__.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/async_timeout/__pycache__/__init__.cpython-37.pyc
  • Date Modified: 05/11/2022 9:51 AM
  • File size: 6.64 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

iIa?@sddlZddlZddlZddlZddlmZddlmZmZm	Z	ej
dkrXddlmZnddlmZdZ
dZeedd	d
dZeeddd
dZGdddejZeGdddZej
dkrejddddZnejddddZej
dkrejdddZnejdddZdS)N)
TracebackType)AnyOptionalType))finalz4.0.2)timeout
timeout_atTimeoutr)delayreturncCs*t}|dk	r||}nd}t||S)artimeout context manager.

    Useful in cases when you want to apply timeout logic around block
    of code or in cases when asyncio.wait_for is not suitable. For example:

    >>> async with timeout(0.001):
    ...     async with aiohttp.get('https://github.com') as r:
    ...         await r.text()


    delay - value in seconds or None to disable timeout logic
    N)_get_running_looptimer)rloopdeadlinerG/opt/alt/python37/lib/python3.7/site-packages/async_timeout/__init__.pyr	s

r	)rr
cCst}t||S)aSchedule the timeout at absolute time.

    deadline argument points on the time in the same clock system
    as loop.time().

    Please note: it is not POSIX time but a time with
    undefined starting base, e.g. the time of the system power on.

    >>> async with timeout_at(loop.time() + 10):
    ...     async with aiohttp.get('https://github.com') as r:
    ...         await r.text()


    )rr)rrrrrr
*sr
c@seZdZdZdZdZdZdS)_StateINITENTERTIMEOUTEXITN)__name__
__module____qualname__rrrrrrrrr=src@s<eZdZdZeeejddddZddddZ	ee
eeeeeee
d	d
dZdddd
Zee
eeeeeee
d	ddZee
dddZeeedddZddddZddddZeddddZeddddZddddZddd d!Zee
edd"d#d$Zd%dd&d'd(ZdS))r)	_deadline_loop_state_timeout_handlerN)rrr
cCs2||_tj|_d|_|dkr$d|_n
||dS)N)rrrrrrupdate)selfrrrrr__init__YszTimeout.__init__)r
cCstjdtdd||S)Nz>with timeout() is deprecated, use async with timeout() instead)
stacklevel)warningswarnDeprecationWarning	_do_enter)r!rrr	__enter__eszTimeout.__enter__)exc_typeexc_valexc_tbr
cCs||dS)N)_do_exit)r!r*r+r,rrr__exit__ns
zTimeout.__exit__cs||S)N)r()r!rrr
__aenter__wszTimeout.__aenter__cs||dS)N)r-)r!r*r+r,rrr	__aexit__{s
zTimeout.__aexit__cCs|jtjkS)z$Is timeout expired during execution?)rrr)r!rrrexpiredszTimeout.expiredcCs|jS)N)r)r!rrrrszTimeout.deadlinecCs0|jtjtjfkr$td|jj|dS)z Reject scheduled timeout if any.zinvalid state N)rrrrRuntimeErrorvalue_reject)r!rrrrejectszTimeout.rejectcCs|jdk	r|jd|_dS)N)rcancel)r!rrrr4s

zTimeout._reject)rr
cCs(|j}|dkrtd|||dS)zAdvance timeout on delay seconds.

        The delay can be negative.

        Raise RuntimeError if shift is called when deadline is not scheduled
        Nz1cannot shift timeout if deadline is not scheduled)rr2r )r!rrrrrshiftsz
Timeout.shift)rr
cCsZ|jtjkrtd|jtjkr(td|jdk	r<|j||_|jtjkrV|	dS)aUSet deadline to absolute value.

        deadline argument points on the time in the same clock system
        as loop.time().

        If new deadline is in the past the timeout is raised immediatelly.

        Please note: it is not POSIX time but a time with
        undefined starting base, e.g. the time of the system power on.
        z1cannot reschedule after exit from context managerz!cannot reschedule expired timeoutN)
rrrr2rrr6rr_reschedule)r!rrrrr s

zTimeout.updatecCs~|jtjkst|j}|dkr"dS|j}|jdk	r@|jt	|j}||krf|j
|j||_n|j||j||_dS)N)
rrrAssertionErrorrrrrr6
_current_taskZ	call_soon_on_timeoutZcall_at)r!rZnowtaskrrrr8s



zTimeout._reschedulecCs2|jtjkrtd|jjtj|_|dS)Nzinvalid state )rrrr2r3rr8)r!rrrr(szTimeout._do_enter)r*r
cCs6|tjkr"|jtjkr"d|_tjtj|_|dS)N)	asyncioZCancelledErrorrrrrTimeoutErrorrr4)r!r*rrrr-szTimeout._do_exitzasyncio.Task[None])r<r
cCs|tj|_d|_dS)N)r6rrrr)r!r<rrrr;szTimeout._on_timeout)rrr	__slots__rfloatr=AbstractEventLoopr"r)r
BaseExceptionrboolr.r/r0propertyr1rr5r4r7r r8r(r-r;rrrrrDs2



	)rzOptional[asyncio.Task[Any]])rr
cCstj|dS)N)r)r=current_task)rrrrr:sr:cCstjj|dS)N)r)r=ZTaskrF)rrrrr:s)r
cCstS)N)r=Zget_running_looprrrrrsrcCst}|std|S)Nzno running event loop)r=Zget_event_loopZ
is_runningr2)rrrrrs)r=enumsysr%typesrtypingrrrversion_inforZtyping_extensions__version____all__r@r	r
EnumrrrAr:rrrrr<module>s*