PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  oYg @sCdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZGdddejZejjZejjZejjZedddddeddZddZeddddZeddZddddd dZedddd!dZddd"d#Zeed Cs z!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks;s  zTask.all_tasksrcstj|s!tt|tjd||jrG|jd=||_d|_d|_ |j j |j |j jj|dS)NrrF)r iscoroutineAssertionErrorreprsuper__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r!add)selfcoror)r/rrr(Es!     z Task.__init__cCsg|jtjkrS|jrSd|ddi}|jrC|j|d<|jj|tjj|dS)Ntaskmessagez%Task was destroyed but it is pending!Zsource_traceback) _staterZ_PENDING_log_destroy_pendingr)rZcall_exception_handlerFuture__del__)r1contextrrrr8Ts   z Task.__del__csrtj}|jr"d|dz wait_for=%r)r' _repr_infor,rZ_format_coroutiner*insertr+)r1infor2)r/rrr;_s  zTask._repr_infolimitc Cs g}y|jj}Wntk r6|jj}YnX|dk rxI|dk r|dk ru|dkrkP|d8}|j||j}qFW|jnj|jdk r|jj}xL|dk r|dk r|dkrP|d8}|j|j |j }qW|S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. Nrr) r*cr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)r1r>Zframesftbrrr get_stackms0             zTask.get_stackfilec Cs]g}t}x|jd|D]}|j}|j}|j}|j} ||krr|j|tj|tj |||j } |j ||| | fq"W|j } |st d|d|n7| dk rt d|d|nt d|d|tj|d|| dk rYx3tj| j| D]} t | d|ddq9WdS) anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. r>zNo stack for %rrLNz)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):end)setrKf_linenof_code co_filenameco_namer0 linecache checkcachegetline f_globalsrBrEprint traceback print_listformat_exception_onlyr/) r1r>rLextracted_listZcheckedrIlinenocofilenamenamelineexcrrr print_stacks0               zTask.print_stackcCsHd|_|jrdS|jdk r;|jjr;dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner+cancelr,)r1rrrres   z Task.cancelcs@|j s%tdj|||jrUt|tjsLtj}d|_|j}d|_||j j |j .)risfuturerr$ TypeErrortyper{ ValueErrorrrrrgrrrO_wait)fsrrrr)rrrLs   cGs|js|jddS)N)rdrn)waiterargsrrr_release_waiterls rccs |dkrtj}|dkr-|EdHS|j}|j|t|}tjt|}t|d|}|j|z|y |EdHWn/t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nr)rr create_future call_laterr functoolspartialr rtrriremove_done_callbackrerdrx TimeoutError)futrrrtimeout_handlecbrrrrqs,             c #s|std|jd|dk rE|j|tt|fdd}x|D]}|j|qsWz EdHWddk rjXtt}}xD|D]<}|j||j r|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. zSet of Futures is empty.Ncsd8dksMtksMtkr||j r||jdk r|dk rcjjs|jddS)Nrr)rr cancelled exceptionrerdrn)rI)counterrrrrr_on_completions      z_wait.._on_completion) r%rrrlenrtrerOrrdr0)rrrrrrIrdpendingr)rrrrrrs(          rc#sLtj|stj|r7tdt|jdk rIn tjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr#|dk r#j||x"ttD]}|Vq6WdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcs"h|]}t|dqS)r)r )rrI)rrrr s zas_completed..r)Queuercs9x(D] }|jjdqWjdS)N)r put_nowaitclear)rI)rrdtodorr _on_timeouts  z!as_completed.._on_timeoutcsEs dSj|j| rAdk rAjdS)N)removerre)rI)rdrrrrrs   z$as_completed.._on_completionc3s0jEdH}|dkr&tj|jS)N)rrrrx)rI)rdrr _wait_for_ones  z#as_completed.._wait_for_one)rrrr$rrr{rrrOqueuesrrrtrranger)rrrrrrrI_r)rrdrrrrrs  c csv|dkrdV|S|dkr-tj}|j}|jj|tj||}z |EdHSWd|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrrrrZ_set_result_unless_cancelledre)delayrxrrzhrrrrs       cCs&tjdtddt|d|S)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future() stacklevelr:r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_s rcCstj|r:|dk r6||jk r6td|Stj|r|dkratj}|j|}|j r|j d=|St j rt j |rtt|d|StddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurerrz:An asyncio.Future, a coroutine or an awaitable is requiredr#)rrrrrr$rrZ create_taskr)rZPY35rvZ isawaitabler _wrap_awaitabler)rrr3rrrr +s     ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrBsrcs:eZdZdZddfddZddZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. rNcs tjd|||_dS)Nr)r'r( _children)r1childrenr)r/rrr(Tsz_GatheringFuture.__init__cCs@|jrdSd}x#|jD]}|jr d}q W|S)NFT)rdrre)r1retZchildrrrreXs   z_GatheringFuture.cancel)r{r|r}r~r(rerr)r/rrLs rreturn_exceptionsFcs|s;|dkrtj}|jjgSixt|D]}tj|st|d|}|dkr|j}d|_ n9|}|dkr|j}n|j|k rt d||s zgather..rcsjr&|js"|jdS|jrXtj}sj|dSn>|jdk r|j}sj|dSn |j}||<d7krjdS)Nr) rdrrrrirmrE_resultrn)irres) nchildren nfinishedouterresultsrrr_done_callbacks&            zgather.._done_callback)rrrrnrOrrr rr6rrr enumeratertrr)rrZcoros_or_futuresrrrrrr)rrrrrrrr bs8            csZt|d|}|jr"|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None rcs~jr&|js"|jdS|jr?jn;|j}|dk rgj|nj|jdS)N)rrrermrnrx)innerrb)rrrrs       zshield.._done_callback)r rdrrrt)rrrrr)rrr s    csStjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcshy tjtdWnAtk rc}z!jrNj|WYdd}~XnXdS)Nr)rZ _chain_futurer rpset_running_or_notify_cancelrm)rb)r2rzrrrcallbacks    z*run_coroutine_threadsafe..callback)rr$r concurrentrr7Zcall_soon_threadsafe)r2rrr)r2rzrrr s   )$r~__all__concurrent.futuresrrrvrTrYrrrNrrrrrr7rrrrrrrrrrrglobalsr{r rrr r r rrrrsP        0    --8   T5