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`  oY @sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddde j'ddddddZ(d d!Z)Gd"d#d#ej*Z+Gd$d d ej,Z-dS)%aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?cCsH|j}tj|r:t|jtjr:t|jSt|SdS)N) _callbackinspectZismethod isinstance__self__rTaskreprstr)handlecbr*/opt/python35/lib/python3.5/base_events.py_format_handle:s $ rcCs4|tjkrdS|tjkr&dSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeCs rc Cs`ttdstdn>y|jtjtjdWntk r[tdYnXdS)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETrOSError)sockrrr_set_reuseportLs  r%cCs|jtj@tjkS)N)typer SOCK_STREAM)r$rrr_is_stream_socketWsr(cCs|jtj@tjkS)N)r&r SOCK_DGRAM)r$rrr_is_dgram_socket^sr*cCsttdsdS|dtjtjhks:|dkr>dS|tjkrYtj}n|tjkrttj}ndS|dkrd}nwt|tr|dkrd}nSt|tr|dkrd}n/yt |}Wnt t fk rdSYnX|tj krAtj g}ttdrJ|jtjn |g}t|trh|jd}d|krxdSxP|D]H}y-tj|||||d||ffSWqtk rYqXqWdS)N inet_ptonrAF_INET6Zidna%)rr IPPROTO_TCP IPPROTO_UDPr'r)rbytesrint TypeErrorr AF_UNSPECAF_INETappendr.decoder+r#)hostportfamilyr&protoZafsafrrr _ipaddr_infoesH              r>r;r&r<flagsc Cs|dd\}}t|||||}|dk rZ|j} | j|g| S|j||d|d|d|d|SdS)Nr;r&r<r?)r> create_future set_result getaddrinfo) addressr;r&r<r?loopr9r:infofutrrr_ensure_resolveds  rHcCs=|j}t|tr,t|t r,dS|jjdS)N) _exceptionr BaseException Exception_loopstop)rGexcrrr_run_until_complete_cbs  rOc@sjeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs(||_||_d|_g|_dS)Nr)rLsockets _active_count_waiters)selfrErQrrr__init__s   zServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rQ)rTrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rR)rTrrr_attachszServer._attachcCs;|jd8_|jdkr7|jdkr7|jdS)Nrr)rRrQ_wakeup)rTrrr_detachszServer._detachcCs`|j}|dkrdSd|_x|D]}|jj|q)W|jdkr\|jdS)Nr)rQrLZ _stop_servingrRrZ)rTrQr$rrrcloses    z Server.closecCs@|j}d|_x'|D]}|js|j|qWdS)N)rSdonerB)rTwaiterswaiterrrrrZs     zServer._wakeupccsN|jdks|jdkr"dS|jj}|jj||EdHdS)N)rQrSrLrAr7)rTr_rrr wait_closeds zServer.wait_closedN) rW __module__ __qualname__rUrXrYr[r\rZrr`rrrrrPs      rPc@seZdZddZddZddZddZd d Zd d Zd dd dd ddZ d dddd dd dd ddZ d d d ddZ d d ddZ d d ddZ ed ddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zed)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zejrd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPdQdPdRdPdSdPdTdUZ*dPdVdWZ+ed d dXd dOdPdRdPdSdPdYd dZd dd d[d\Z,edd]d^Z-ed d dOdPdRdPdSdPd_d d`d dad dYd dbdcZ.edddeZ/ed d dOe0j1dSe0j2dYd dfdgdXd d_d d`d dhdiZ3edXd djdkZ4edldmZ5edndoZ6dpdqZ7edre8j9dse8j9dte8j9duddvdwdxdPdydzZ:edre8j9dse8j9dte8j9duddvddxdPd{d|Z;d}d~Z<ddZ=ddZ>ddZ?ddZ@ddZAddZBddZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj ottjjdd|_d|_d|_d|_ttdrtj|_n d|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysr?ignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rTrrrrUs(             zBaseEventLoop.__init__cCs,d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rVrW is_running is_closed get_debug)rTrrrrX szBaseEventLoop.__repr__cCstjd|S)z,Create a Future object attached to the loop.rE)rFuture)rTrrrrAszBaseEventLoop.create_futurecCsZ|j|jdkrDtj|d|}|jrV|jd=n|j||}|S)zDSchedule a coroutine object. Return a task object. NrEr) _check_closedr{rr_source_traceback)rTcoroZtaskrrr create_tasks   zBaseEventLoop.create_taskcCs2|dk r%t| r%td||_dS)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler4r{)rTfactoryrrrset_task_factory#s  zBaseEventLoop.set_task_factorycCs|jS)zs z4BaseEventLoop.shutdown_asyncgens..Zreturn_exceptionsrEmessagez?an error occurred during closing of asynchronous generator {!r} exceptionZasyncgen) rrlenlistclearrgatherziprrKcall_exception_handlerr)rTZ closing_agensZ shutdown_cororesultsresultrrrrshutdown_asyncgensxs"     z BaseEventLoop.shutdown_asyncgensc Cs|j|jr"tdtjdk r@td|j|jtj|_ |j dk rt j }t j d|jd|jz,tj|x|j|jrPqWWdd|_d|_ tjd|jd|j dk r t j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is runningZ firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrmrrsrdZset_asyncgen_hooksrrZ_set_running_loop _run_oncerg)rTZold_agen_hooksrrr run_forevers0              zBaseEventLoop.run_forevercCs|jtj| }tj|d|}|r>d|_|jtzIy|jWn4|r|j r|j r|j YnXWd|j tX|j st d|jS)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. rEFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingadd_done_callbackrOrr] cancelledrZremove_done_callbackrr)rTfutureZnew_taskrrrrun_until_completes       z BaseEventLoop.run_until_completecCs d|_dS)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rg)rTrrrrMszBaseEventLoop.stopcCs|jrtd|jr%dS|jr>tjd|d|_|jj|jj|j }|dk rd|_ |j dddS)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTwaitF) rrrfrr debugrjrrkrlshutdown)rTexecutorrrrr\s          zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rf)rTrrrrszBaseEventLoop.is_closedcCs:|js6tjd|t|js6|jdS)Nzunclosed event loop %r)rrrrrr\)rTrrr__del__s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rm)rTrrrrszBaseEventLoop.is_runningcCs tjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rnrc)rTrrrrnszBaseEventLoop.timecGs6|j|j|||}|jr2|jd=|S)a8Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrnr)rTdelaycallbackrtimerrrr call_laters  zBaseEventLoop.call_latercGsx|j|jr-|j|j|dtj||||}|jrX|jd=tj|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. rrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushrk)rTwhenrrrrrrr#s      zBaseEventLoop.call_atcGsV|j|jr-|j|j|d|j||}|jrR|jd=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonrr)rrrr _call_soonr)rTrrrrrrr3s     zBaseEventLoop.call_sooncCs[tj|stj|r3tdj|t|sWtdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr4rr)rTrmethodrrrrFs zBaseEventLoop._check_callbackcCs<tj|||}|jr(|jd=|jj||S)Nrr)rZHandlerrjr7)rTrrrrrrrQs   zBaseEventLoop._call_sooncCs>|jdkrdStj}||jkr:tddS)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rmrrr)rTZ thread_idrrrrXs  zBaseEventLoop._check_threadcGsV|j|jr#|j|d|j||}|jrH|jd=|j|S)z"Like call_soon(), but thread-safe.call_soon_threadsaferr)rrrrrr)rTrrrrrrris     z"BaseEventLoop.call_soon_threadsafecGs{|j|jr#|j|d|dkr\|j}|dkr\tjj}||_tj|j||d|S)Nrun_in_executorrE) rrrrl concurrentrThreadPoolExecutorZ wrap_futuresubmit)rTrfuncrrrrrts      zBaseEventLoop.run_in_executorcCs ||_dS)N)rl)rTrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r*|jd||rA|jd||rX|jd||ro|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r7joinr rrnrrCryrF) rTr9r:r;r&r<r?msgt0Zaddrinfodtrrr_getaddrinfo_debugs(  z BaseEventLoop._getaddrinfo_debugr;rr&r<r?c CsW|jr.|jd|j||||||S|jdtj||||||SdS)N)rrrrrC)rTr9r:r;r&r<r?rrrrCs  zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rTZsockaddrr?rrrrszBaseEventLoop.getnameinfosslr$ local_addrc#s#| dk r| rtd| dkrI|rI|sCtd|} |dk sa|dk r|dk rytdt||fd|dtjd|d|d |} | g} | dk rt| d|dtjd|d|d |} | j| nd} tj| d |EdH| j}|s:td | dk rd| j}|sdtd g}xU|D]\}}}}}y tjd|d|d|}|j d | dk rax|D]\}}}}}y|j |PWqtk rI}z9t|j d j ||j j}|j|WYdd}~XqXqW|jd}wq|jr}tjd |||j||EdHWnhtk r}z(|dk r|j|j|WYdd}~Xqq|dk r|jYqqXPqqWt|dkr"|dqt|dtfdd|Dr[|dtdj djdd|Dn9|dkrtdt|stdj ||j|||| EdH\}}|jr|jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same timer;r&r<r?rEz!getaddrinfo() returned empty listFz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s!|]}t|kVqdS)N)r)rrN)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrNrrrrsz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}rz%r connected to %s:%r: (%r, %r))r rHrr'r7rrrr# setblockingbinderrnorstrerrorlowerr\rr r sock_connectrrallrr(_create_connection_transportget_extra_info)rTprotocol_factoryr9r:rr;r<r?r$rrf1fsf2infosZ laddr_infos exceptionsr&ZcnamerD_laddrrN transportrr)rrcreate_connections                $         %     zBaseEventLoop.create_connectionc cs|jd|}|j}|rjt|tr=dn|}|j||||d|d|} n|j|||} y |EdHWn| jYnX| |fS)NFrr)rrArrurrr\) rTr$rrrrrr_rrrrrr+s     z*BaseEventLoop._create_connection_transport reuse_address reuse_portallow_broadcastc#sT| dk rt| s-tdj| s]s]|s]|s]|s]|s]|s]| rtddd|d|d|d|d |d | } d jd d | jD} tdj| | jdd} nps|dkrtd||fdff}ntj}xdfdffD]\}}|dk rDt |d|dt j d|d|d|EdH}|st dxS|D]K\}}}}}||f}||krddg||<||||.zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrr&rEz!getaddrinfo() returned empty listcsNg|]D\}}r(|ddkp;o;|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrxs z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwinz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN) r*r rdictritemsrrh OrderedDictrHrr)r#rvnamersplatformr!r" SO_REUSEADDRr% SO_BROADCASTrrr\r7rArrr rFr)rTrrrr;r<r?rrrr$ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxaddrrZfamrZprorDrrZ local_addressZremote_addressrNrr_rr)rrrcreate_datagram_endpointCs            %    "                    z&BaseEventLoop.create_datagram_endpointc csQt||fd|dtjd|d|EdH}|sMtdj||S)Nr;r&r?rEz%getaddrinfo({!r}) returned empty list)rHrr'r#r)rTr9r:r;r?rrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfobacklogr c #sdt|trtd|dk s3dk r|dk rKtdttdd} | dkrtjdkotj dk} g} |dkrdg} n4t|t st|t j  r|g} n|} fd d | D}t j|d EdH}ttjj|}d }zWxJ|D]B}|\}}}}}ytj|||}Wn=tjk rjrtjd |||ddw=YnX| j|| r|jtjtjd| rt||| kr!ttdr!|jtjtjdy|j|Wq=t k r~}z*t |j!d||j"j#fWYdd}~Xq=Xq=Wd}Wd|sx| D]}|j$qWXnB|dkrtdt%|stdj&||g} t'| }xA| D]9}|j(||j)d j*|||||q Wjr`tj+d||S)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNz8host/port and sock can not be specified at the same timer.rrrr-c s.g|]$}j|ddqS)r;r?)r)rr9)r;r?r:rTrrrs z/BaseEventLoop.create_server..rEFz:create_server() failed to create socket.socket(%r, %r, %r)exc_infoT IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving),rrur4r getattrrrvr rsr rrhIterablerrset itertoolschain from_iterableerrorrr warningr7r!r"rr%rr IPV6_V6ONLYrr#rrrr\r(rrPlistenrZ_start_servingrF)rTrr9r:r;r?r$rrrrr.rQZhostsrrZ completedresr=socktyper< canonnamesaerrrr)r;r?r:rTr create_servers               0          zBaseEventLoop.create_serverccst|s!tdj||j|||dddEdH\}}|jrx|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r-rTNrz%r handled: (%r, %r))r(r rrrrr r)rTrr$rrrrrrconnect_accepted_socket.s # z%BaseEventLoop.connect_accepted_socketc cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rArr\rr rfileno)rTrrrr_rrrrconnect_read_pipeEs      zBaseEventLoop.connect_read_pipec cs~|}|j}|j|||}y |EdHWn|jYnX|jrttjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rArr\rr rr()rTrrrr_rrrrconnect_write_pipeVs      z BaseEventLoop.connect_write_pipecCs|g}|dk r,|jdt||dk ra|tjkra|jdt|nF|dk r|jdt||dk r|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r7rrrr rr)rTrrrrrFrrr_log_subprocessgs    zBaseEventLoop._log_subprocessrrruniversal_newlinesrTrc kst|ttfs!td|r3td|sEtd|dkr]td|} |jrd|} |j| ||||j| |d||||| EdH} |jrtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr2rr rr,rr rF) rTrcmdrrrr-rrrr debug_logrrrrsubprocess_shellts"        # zBaseEventLoop.subprocess_shellc os |rtd|r$td|dkr<td|f| } x<| D]4} t| ttfsPtdt| jqPW|} |jrd|}|j|||||j | | d||||| EdH}|jrt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r rrr2r4r&rWrr,rr rF)rTrZprogramrrrr-rrrrZ popen_argsargrr/rrrrsubprocess_execs*          zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rq)rTrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs;|dk r.t| r.tdj|||_dS)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz/A callable object or None is expected, got {!r})rr4rrq)rThandlerrrrset_exception_handlers   z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk rQt|||jf}nd}d|kr|jdk r|jjr|jj|d<|g}xt|D]}|dkrq||}|dkrdjtj|}d }||j 7}nI|dkr=djtj|}d }||j 7}n t |}|j d j ||qWt jd j|d |dS)a@Default exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr-z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} r>rr)rxr& __traceback__rzrsortedr traceback format_listrstriprr7rr r) rTcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6          z'BaseEventLoop.default_exception_handlercCs|jdkrKy|j|Wqtk rGtjdddYqXny|j||Wnptk r}zPy#|jddd|d|iWn%tk rtjd ddYnXWYdd}~XnXdS) aCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerrTrz$Unhandled error in exception handlerrr<zeException in default exception handler while handling an unexpected error in custom exception handler)rqr?rKr r)rTr<rNrrrrs"    z$BaseEventLoop.call_exception_handlercCs!|jr dS|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrjr7)rTrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)rAr)rTrrrr_add_callback_signalsafe's z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rkre)rTrrrr_timer_handle_cancelled,s z%BaseEventLoop._timer_handle_cancelledc Cslt|j}|tkr|j|tkrg}x3|jD](}|jrYd|_q>|j|q>Wtj|||_d|_nJxG|jr|jdjr|jd8_tj |j}d|_qWd}|j s|j rd}n2|jr)|jdj }t d||j}|jr|dkr|j}|jj|}|j|}|dkrtj} n tj} t|} |dkrtj| d|d| q+| rtj| d|d|d| q+|dkr+tj| d |d|dn|jj|}|j||j|j} xU|jr|jd}|j | krtPtj |j}d|_|j j|qNWt|j } xt| D]} |j j}|jrq|jrTz[||_|j}|j|j|}||jkrCtjd t||Wdd|_Xq|jqWd}dS) zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds) rrk_MIN_SCHEDULED_TIMER_HANDLESre%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr@r7rheapifyheappoprjrgZ_whenmaxrnr _selectorselectloggingINFODEBUGr logrrprangepopleftrzZ_runryrr)rTZ sched_countZ new_scheduledrtimeoutrrrrlevelZneventend_timeZntodoirrrr1s                                zBaseEventLoop._run_oncec Csytj}tj}Wntk r.dSYnXt|}|j|krNdStj}|}|r|d|fkrtj d|t q||d|_n<|d|fkrtj d|t n|dd|_dS)Nz[loop.set_debug(True): cannot set debug coroutine wrapper; another wrapper is already set %rTzWloop.set_debug(False): cannot unset debug coroutine wrapper; another wrapper was set %rF) rsset_coroutine_wrapperget_coroutine_wrapperAttributeErrorrur|rZ debug_wrapperrrRuntimeWarning)rTenabledZ set_wrapperZ get_wrapperwrapperZcurrent_wrapperrrrrs.          z$BaseEventLoop._set_coroutine_wrappercCs|jS)N)r)rTrrrrszBaseEventLoop.get_debugcCs&||_|jr"|j|dS)N)rrr)rTrYrrrrrs  zBaseEventLoop.set_debug)GrWrarbrUrXrArrrrrrrrrrrrrrrrrrrMr\rrZPY34rrrnrrrrrrrrrrrCrrrrrrr5 AI_PASSIVEr&r'r)r*r,rrr0r2r3r5r?rrArBrCrrrrrrrrrr s  !            %             !   u    _     , 2    c ! ).__doc__rhconcurrent.futuresrrr rrKrvrrrrnr9rsrr}r-rrrrrrrNr __all__rDrEBrokenPipeErrorConnectionResetErrorConnectionAbortedErrorZ_FATAL_ERROR_IGNORErrr%r(r*r>r'rHrOZAbstractServerrPZAbstractEventLoopr rrrrsL                    = /