HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asgiref/__pycache__/timeout.cpython-310.pyc
o

��h+�@sJddlZddlZddlmZddlmZddlmZmZGdd�d�ZdS)�N)�
TracebackType)�Any)�Optional�Typec	@s�eZdZdZdd�deedeejddfdd�Zddd	�Z	d
e
edededee
fd
d�Zddd�Zd
e
edededdfdd�Zede
fdd��Zedeefdd��Zddd�Zd
e
eddfdd�Zddd�ZdS)�timeouta�timeout 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:

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


    timeout - value in seconds or None to disable timeout logic
    loop - asyncio compatible event loop
    N)�loopr�returncCsF||_|durt��}nt�dt�||_d|_d|_d|_	d|_
dS)Nz-The loop argument to timeout() is deprecated.F)�_timeout�asyncio�get_running_loop�warnings�warn�DeprecationWarning�_loop�_task�
_cancelled�_cancel_handler�
_cancel_at)�selfrr�r�E/usr/local/CyberPanel/lib/python3.10/site-packages/asgiref/timeout.py�__init__s
�
ztimeout.__init__cCs|��S�N��	_do_enter�rrrr�	__enter__2sztimeout.__enter__�exc_type�exc_val�exc_tbcCs|�|�dSr��_do_exit�rrrrrrr�__exit__5s
ztimeout.__exit__c�s
�|��Srrrrrr�
__aenter__>s�ztimeout.__aenter__c�s�|�|�dSrr r"rrr�	__aexit__As�ztimeout.__aexit__cCs|jSr)rrrrr�expiredIsztimeout.expiredcCs$|jdurt|j|j��d�SdS)Ng)r�maxr�timerrrr�	remainingMs
ztimeout.remainingcCst|jdur|St�|j�|_|jdurtd��|jdkr%|j�|j�|S|j��|j|_	|j�
|j	|j�|_|S)Nz4Timeout context manager should be used inside a taskr)r	r
�current_taskrr�RuntimeError�	call_soon�_cancel_taskr(r�call_atrrrrrrTs

�
ztimeout._do_entercCsP|tjur|jrd|_d|_tj�|jdur#|jdur#|j��d|_d|_dSr)r
�CancelledErrorrrr�TimeoutErrorr	�cancel)rrrrrr!hs
ztimeout._do_exitcCs"|jdur|j��d|_dSdS)NT)rr1rrrrrr-ss


�ztimeout._cancel_task)rr)rN)�__name__�
__module__�__qualname__�__doc__r�floatr
�AbstractEventLooprrr�
BaseExceptionr�boolr#r$r%�propertyr&r)rr!r-rrrrrsJ���
�
���
�
	���
�
r)	r
r�typesr�typingrrrrrrrr�<module>s