B `F@sbddlZddlZddlmZddlmZmZmZdZej dkZ GdddZ ej dd d d Z dS) N) TracebackType)OptionalTypeAnyz3.0.1)c@seZdZdZddeeeejddddZdddd Z e e e e ee d d d Zddd dZe e e e dd ddZee dddZeeedddZddddZe e ddddZddddZdS)timeoutatimeout 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)loop)rr returncCs8||_|dkrt}||_d|_d|_d|_d|_dS)NF)_timeoutasyncioZget_event_loop_loop_task _cancelled_cancel_handler _cancel_at)selfrr rq/private/var/folders/7j/8686xlfs15q3tgljmghtvg0r0000gn/T/pip-target-isidps9b/lib/python/async_timeout/__init__.py__init__sztimeout.__init__)r cCs|S)N) _do_enter)rrrr __enter__&sztimeout.__enter__)exc_typeexc_valexc_tbr cCs||dS)N)_do_exit)rrrrrrr__exit__)s ztimeout.__exit__cs|S)N)r)rrrr __aenter__0sztimeout.__aenter__cs||dS)N)r)rrrrrrr __aexit__3sztimeout.__aexit__cCs|jS)N)r)rrrrexpired9sztimeout.expiredcCs(|jdk r t|j|jdSdSdS)Ng)rmaxr time)rrrr remaining=s ztimeout.remainingcCsr|jdkr|St|j|_|jdkr,td|jdkrH|j|j|S|j|j|_|j |j|j|_ |S)Nz4Timeout context manager should be used inside a taskr) r current_taskr r RuntimeErrorZ call_soon _cancel_taskr!rZcall_atr)rrrrrDs    ztimeout._do_enter)rr cCsP|tjkr"|jr"d|_d|_tj|jdk rF|jdk rF|jd|_d|_dS)N)r ZCancelledErrorrrr TimeoutErrorr cancel)rrrrrrXs ztimeout._do_exitcCs|jdk r|jd|_dS)NT)rr'r)rrrrr%cs  ztimeout._cancel_task)__name__ __module__ __qualname____doc__rfloatr AbstractEventLooprrr BaseExceptionrboolrrrpropertyrr"rrr%rrrrr s" "  rzasyncio.Task[Any])r r cCs>trtj|d}ntjj|d}|dkr:t|dr:|}|S)N)r r#)PY_37r r#ZTaskhasattr)r Ztaskrrrr#is r#)r systypesrtypingrrr __version__ version_infor1rr-r#rrrrs  \