/usr/lib64/python3.6/asyncio/__pycache__
NameSizeModeActions
base_events.cpython-36.opt-1.pyc391090644editdlrm
base_events.cpython-36.opt-2.pyc312570644editdlrm
base_events.cpython-36.pyc393470644editdlrm
base_futures.cpython-36.opt-1.pyc20490644editdlrm
base_futures.cpython-36.opt-2.pyc17050644editdlrm
base_futures.cpython-36.pyc20490644editdlrm
base_subprocess.cpython-36.opt-1.pyc91680644editdlrm
base_subprocess.cpython-36.opt-2.pyc90660644editdlrm
base_subprocess.cpython-36.pyc92640644editdlrm
base_tasks.cpython-36.opt-1.pyc18630644editdlrm
base_tasks.cpython-36.opt-2.pyc18630644editdlrm
base_tasks.cpython-36.pyc18630644editdlrm
compat.cpython-36.opt-1.pyc7340644editdlrm
compat.cpython-36.opt-2.pyc6150644editdlrm
compat.cpython-36.pyc7340644editdlrm
constants.cpython-36.opt-1.pyc2530644editdlrm
constants.cpython-36.opt-2.pyc2260644editdlrm
constants.cpython-36.pyc2530644editdlrm
coroutines.cpython-36.opt-1.pyc84460644editdlrm
coroutines.cpython-36.opt-2.pyc82140644editdlrm
coroutines.cpython-36.pyc85540644editdlrm
events.cpython-36.opt-1.pyc252320644editdlrm
events.cpython-36.opt-2.pyc176570644editdlrm
events.cpython-36.pyc253400644editdlrm
futures.cpython-36.opt-1.pyc135040644editdlrm
futures.cpython-36.opt-2.pyc76340644editdlrm
futures.cpython-36.pyc137490644editdlrm
locks.cpython-36.opt-1.pyc154500644editdlrm
locks.cpython-36.opt-2.pyc89120644editdlrm
locks.cpython-36.pyc154500644editdlrm
log.cpython-36.opt-1.pyc2200644editdlrm
log.cpython-36.opt-2.pyc1810644editdlrm
log.cpython-36.pyc2200644editdlrm
proactor_events.cpython-36.opt-1.pyc166390644editdlrm
proactor_events.cpython-36.opt-2.pyc162390644editdlrm
proactor_events.cpython-36.pyc168240644editdlrm
protocols.cpython-36.opt-1.pyc59790644editdlrm
protocols.cpython-36.opt-2.pyc22220644editdlrm
protocols.cpython-36.pyc59790644editdlrm
queues.cpython-36.opt-1.pyc84060644editdlrm
queues.cpython-36.opt-2.pyc55430644editdlrm
queues.cpython-36.pyc84060644editdlrm
selector_events.cpython-36.opt-1.pyc295110644editdlrm
selector_events.cpython-36.opt-2.pyc279200644editdlrm
selector_events.cpython-36.pyc295690644editdlrm
sslproto.cpython-36.opt-1.pyc201430644editdlrm
sslproto.cpython-36.opt-2.pyc133130644editdlrm
sslproto.cpython-36.pyc203450644editdlrm
streams.cpython-36.opt-1.pyc196360644editdlrm
streams.cpython-36.opt-2.pyc133580644editdlrm
streams.cpython-36.pyc199170644editdlrm
subprocess.cpython-36.opt-1.pyc67960644editdlrm
subprocess.cpython-36.opt-2.pyc66290644editdlrm
subprocess.cpython-36.pyc68260644editdlrm
tasks.cpython-36.opt-1.pyc189170644editdlrm
tasks.cpython-36.opt-2.pyc120140644editdlrm
tasks.cpython-36.pyc190950644editdlrm
test_utils.cpython-36.opt-1.pyc175170644editdlrm
test_utils.cpython-36.opt-2.pyc162190644editdlrm
test_utils.cpython-36.pyc176830644editdlrm
transports.cpython-36.opt-1.pyc120320644editdlrm
transports.cpython-36.opt-2.pyc64150644editdlrm
transports.cpython-36.pyc120620644editdlrm
unix_events.cpython-36.opt-1.pyc302140644editdlrm
unix_events.cpython-36.opt-2.pyc265150644editdlrm
unix_events.cpython-36.pyc305570644editdlrm
windows_events.cpython-36.opt-1.pyc214960644editdlrm
windows_events.cpython-36.opt-2.pyc203840644editdlrm
windows_events.cpython-36.pyc214960644editdlrm
windows_utils.cpython-36.opt-1.pyc52940644editdlrm
windows_utils.cpython-36.opt-2.pyc47090644editdlrm
windows_utils.cpython-36.pyc53840644editdlrm
__init__.cpython-36.opt-1.pyc7800644editdlrm
__init__.cpython-36.opt-2.pyc7240644editdlrm
__init__.cpython-36.pyc7800644editdlrm
Edit: /usr/lib64/python3.6/asyncio/__pycache__/futures.cpython-36.opt-1.pyc (13504B)
3 \>ã @s dZddddddgZddlZddlZddlZddlZd d lmZd d lm Z d d lm Z ej Z ej Z ej Z ejZejZejZejZejd ZGd d„dƒZGdd„dƒZeZdd„Zdd„Zdd„Zdd„Zddœdd„Zy ddlZWnek rúYn XejZZdS)z.A Future class similar to the one in PEP 3148.ÚCancelledErrorÚ TimeoutErrorÚInvalidStateErrorÚFutureÚ wrap_futureÚisfutureéNé)Ú base_futures)Úcompat)Úeventsc@s4eZdZdZdZdd„Zdd „Zd d „Zd d „ZdS)Ú_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. ÚloopÚsource_tracebackÚexcÚtbcCs |j|_|j|_||_d|_dS)N)Ú_loopr Ú_source_tracebackrrr)ÚselfÚfuturer©rú'/usr/lib64/python3.6/asyncio/futures.pyÚ__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||jƒ|_dS)N)rÚ tracebackÚformat_exceptionÚ __class__Ú __traceback__r)rrrrrÚactivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrÚclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|jƒƒ}|d7}|d|jƒ7}|dj|jƒjƒ7}|jjd|iƒdS)Nz*Future/Task exception was never retrieved Úz0Future/Task created at (most recent call last): z%s Úmessage)rrÚjoinrÚ format_listÚrstripr Úcall_exception_handler)rÚmsgÚsrcrrrÚ__del__csz_TracebackLogger.__del__N)r rrr) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú __slots__rrrr&rrrrr s 0r c@s¸eZdZdZeZdZdZdZdZ dZ dZ ddœdd„Z e jZdd„ZejrRd d „Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zejr´eZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF)r cCs@|dkrtjƒ|_n||_g|_|jjƒrú )rr'r Ú _repr_info)rrrrÚ__repr__¥szFuture.__repr__cCsD|js dS|j}d|jj||dœ}|jr4|j|d<|jj|ƒdS)Nz %s exception was never retrieved)rÚ exceptionrr)Ú_log_tracebackÚ _exceptionrr'rrr#)rrÚcontextrrrr&¬s zFuture.__del__cCs&d|_|jtkrdSt|_|jƒdS)záCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r5Ú_stateÚ_PENDINGÚ _CANCELLEDÚ_schedule_callbacks)rrrrÚcancel¼s  z Future.cancelcCsD|jdd…}|sdSg|jdd…<x|D]}|jj||ƒq*WdS)zªInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N)r-rÚ call_soon)rZ callbacksÚcallbackrrrr;Ês  zFuture._schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r8r:)rrrrÚ cancelledØszFuture.cancelledcCs |jtkS)z™Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r8r9)rrrrÚdoneÞsz Future.donecCs<|jtkrt‚|jtkr tdƒ‚d|_|jdk r6|j‚|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN)r8r:rÚ _FINISHEDrr5r6Ú_result)rrrrÚresultæs   z Future.resultcCs,|jtkrt‚|jtkr tdƒ‚d|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r8r:rrArr5r6)rrrrr4ös   zFuture.exceptioncCs*|jtkr|jj||ƒn |jj|ƒdS)zøAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r8r9rr=r-Úappend)rÚfnrrrÚadd_done_callbacks zFuture.add_done_callbackcs<‡fdd„|jDƒ}t|jƒt|ƒ}|r8||jdd…<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. csg|]}|ˆkr|‘qSrr)Ú.0Úf)rErrú sz/Future.remove_done_callback..N)r-Úlen)rrEZfiltered_callbacksZ removed_countr)rErÚremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|ƒƒ‚||_t|_|jƒdS)z–Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r8r9rÚformatrBrAr;)rrCrrrÚ set_result s  zFuture.set_resultcCs‚|jtkrtdj|j|ƒƒ‚t|tƒr,|ƒ}t|ƒtkr@tdƒ‚||_t |_|j ƒt j rbd|_ nt||ƒ|_|jj|jjƒdS)z˜Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrLÚ isinstanceÚtypeÚ StopIterationÚ TypeErrorr6rAr;r ÚPY34r5r Z _tb_loggerrr=r)rr4rrrÚ set_exception,s    zFuture.set_exceptionccs|jƒsd|_|V|jƒS)NT)r@Ú_asyncio_future_blockingrC)rrrrÚ__iter__DszFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr Z_future_repr_infor2r3r rRr&r<r;r?r@rCr4rFrKrMrSrUZPY35Ú __await__rrrrrns4   cCs|jƒr dS|j|ƒdS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrrÚ_set_result_unless_cancelledSsrWcCsN|jƒr|jƒ|jƒsdS|jƒ}|dk r8|j|ƒn|jƒ}|j|ƒdS)z8Copy state from a future to a concurrent.futures.Future.N)r?r<Zset_running_or_notify_cancelr4rSrCrM)Ú concurrentÚsourcer4rCrrrÚ_set_concurrent_future_stateZs rZcCsP|jƒr dS|jƒr|jƒn.|jƒ}|dk r:|j|ƒn|jƒ}|j|ƒdS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r?r<r4rSrCrM)rYÚdestr4rCrrrÚ_copy_future_stateis  r\csªtˆƒ r"tˆtjjƒ r"tdƒ‚tˆƒ rDtˆtjjƒ rDtdƒ‚tˆƒrRˆjnd‰tˆƒrdˆjnd‰dd„‰‡‡‡fdd„}‡‡‡‡fdd „}ˆj|ƒˆj|ƒdS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|ƒrt||ƒn t||ƒdS)N)rr\rZ)rÚotherrrrÚ _set_states z!_chain_future.._set_statecs2|jƒr.ˆdksˆˆkr"ˆjƒn ˆjˆjƒdS)N)r?r<Úcall_soon_threadsafe)Ú destination)Ú dest_looprYÚ source_looprrÚ_call_check_cancel“s z)_chain_future.._call_check_cancelcsJˆjƒrˆdk rˆjƒrdSˆdks,ˆˆkr8ˆˆ|ƒnˆjˆˆ|ƒdS)N)r?Z is_closedr_)rY)r^rar`rbrrÚ_call_set_statešs  z&_chain_future.._call_set_state)rrNrXZfuturesrrQrrF)rYr`rcrdr)r^rar`rYrbrÚ _chain_future}s   re)r cCs2t|ƒr |S|dkrtjƒ}|jƒ}t||ƒ|S)z&Wrap concurrent.futures.Future object.N)rr r,Z create_futurere)rr Z new_futurerrrr§s )r*Ú__all__Zconcurrent.futuresrXZloggingr/rrr r r rrrrr9r:rAÚDEBUGZ STACK_DEBUGr rZ _PyFuturerWrZr\rerZ_asyncioÚ ImportErrorZ_CFuturerrrrÚs>     Pc*