← Back
Editing: timeout.cpython-311.pyc
� "z�c+ � �X � d dl Z d dlZd dlmZ d dlmZ d dlmZmZ G d� d� � ZdS )� N)� TracebackType)�Any)�Optional�Typec �" � e Zd ZdZdd�d ee deej ddfd�Zdd�Z de e d ed edee fd�Zdd�Zde e d ed eddfd �Zede fd�� � Zedee fd�� � Zdd�Zde e ddfd�Zdd�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 �returnc � � || _ |�t j � � }nt j dt � � || _ d | _ d| _ d | _ d | _ d S )Nz-The loop argument to timeout() is deprecated.F)�_timeout�asyncio�get_running_loop�warnings�warn�DeprecationWarning�_loop�_task� _cancelled�_cancel_handler� _cancel_at)�selfr r s �1/usr/lib/python3/dist-packages/asgiref/timeout.py�__init__ztimeout.__init__ sd � � �� ��<��+�-�-�D�D��M�C�EW� � � � �� ��� ����#�������� c �* � | � � � S �N�� _do_enter�r s r � __enter__ztimeout.__enter__2 s � ��~�~���r �exc_type�exc_val�exc_tbc �0 � | � |� � d S r ��_do_exit�r r! r"