asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T a bYh!@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZz ddlZWneydZYn0ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%e dZ&dZ'e(Z)ddZ*ddZ+ddZ,d-ddZ-d.ddZ.dd Z/e%e d!rd"d#Z0nd$d#Z0d%d&Z1Gd'd(d(ej2Z3Gd)d*d*ej4Z5Gd+d,d,ej6Z7dS)/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) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks) transports)trsock)logger) BaseEventLoopServerdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__) _callback isinstancegetattrr Taskreprrstr)handlecbr//usr/local/lib/python3.9/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r#cCsJttdstdn2z|tjtjdWntyDtdYn0dS)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_SOCKETr$OSErrorsockrrr_set_reuseport\s    r-c CsttdsdS|dtjtjhvs(|dur,dS|tjkr>tj}n|tjkrPtj}ndS|durbd}nVt|trz|dkrzd}n>t|tr|dkrd}n&z t |}Wnt t fyYdS0|tj krtj g}tr|tjn|g}t|tr|d}d|vrdS|D]r}zVt||trH|tjkrH|||d||||ffWS|||d||ffWSWntyvYn0qdS)N inet_ptonrZidna%)r%r& IPPROTO_TCP IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr' AF_UNSPECAF_INET _HAS_IPv6appendrdecoder.r*) hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rDcCst}|D]*}|d}||vr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dur|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr<listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr@Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rScCs4|s"|}t|ttfr"dSt|dSrE) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs r[ TCP_NODELAYcCs@|jtjtjhvr<|jtjkr<|jtjkr<|tjtj ddSNr) r@r&r:rrAr4rBr2r(r\r+rrr _set_nodelays   r^cCsdSrErr+rrrr^scCs tdurt|tjrtddS)Nz"Socket cannot be of type SSLSocket)sslrZ SSLSocketr8r+rrr_check_ssl_socketsr`c@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr8 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dur$dS|IdHdS)NzConnection closed by peer)rb is_closingConnectionErrorrj)rkrYrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rk transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdur0|dur$|jtdn |j||j|dS)NzConnection is closed by peer)rj set_exceptionrorcconnection_lost)rkrZrrrrvs  z)_SendfileFallbackProtocol.connection_lostcCs |jdurdS|jj|_dSrE)rjrbrhrirkrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdurdS|jdd|_dS)NF)rj set_resultrwrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrq)rkdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSr{rqrwrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdur2|j|jrB|jdSrE) rbrgrcrdresume_readingrjcancelrerzrwrrrrestore s   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rmrprtrvrxrzr}r~rrrrrras rac@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)rcCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rh_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rkloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrmszServer.__init__cCsd|jjd|jdS)N) __class__rrrwrrr__repr__%szServer.__repr__cCs |jdusJ|jd7_dSr])rrrwrrr_attach(szServer._attachcCs<|jdksJ|jd8_|jdkr8|jdur8|dS)Nrr)rr_wakeuprwrrr_detach,szServer._detachcCs,|j}d|_|D]}|s||qdSrE)rdonery)rkwaiterswaiterrrrr2s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdS)NT) rrlistenrrh_start_servingrrr)rkr,rrrr9s    zServer._start_servingcCs|jSrE)rhrwrrrget_loopCszServer.get_loopcCs|jSrE)rrwrrr is_servingFszServer.is_servingcCs"|jdurdStdd|jDS)Nrcss|]}t|VqdSrE)r ZTransportSocket)rFsrrrrHMr/z!Server.sockets..)rtuplerwrrrrIs zServer.socketscCsn|j}|durdSd|_|D]}|j|qd|_|jdurX|jsX|jd|_|jdkrj|dS)NFr) rrhZ _stop_servingrrrrrr)rkrr,rrrcloseOs   z Server.closecs|tdIdHdS)Nr)rr sleeprwrrr start_servingbszServer.start_servingc s|jdurtd|d|jdur4td|d||j|_zRz|jIdHWn6tjyz|| IdHWn0Yn0Wd|_nd|_0dS)Nzserver z, is already being awaited on serve_forever()z is closed) rrrrrrhrirCancelledErrorr wait_closedrwrrr serve_foreverhs     zServer.serve_forevercs<|jdus|jdurdS|j}|j||IdHdSrE)rrrhrir<)rkrrrrr}s   zServer.wait_closedN)rrrrmrrrrrrrpropertyrrrrrrrrrrs   rc @sheZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zejfd=d>Z d?d@Z!dAdBZ"ddCdDdEZ#ddCdFdGZ$ddCdHdIZ%dJdKZ&dLdMZ'dNdOZ(ddCdPdQZ)dRdSZ*dTdUZ+dVdWZ,dXdXdXdXdYdZd[Z-dd\d]Z.ddd^d_d`Z/dadbZ0dcddZ1dedfZ2ddgdhZ3dddXdXdXdddddddi djdkZ4ddldmZ5ddd^dndoZ6dpdqZ7drdsZ8ddddtdudvZ9ddXdXdXe:ddddwdxdyZ;dXed|d}Z?de$r/z4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerUZasyncgen) rlenrrKclearr _gatherzipr Exceptioncall_exception_handler)rkZ closing_agensresultsresultrrrrshutdown_asyncgenss&     z BaseEventLoop.shutdown_asyncgenscs\d|_|jdurdS|}tj|j|fd}|z|IdHW|n |0dS)z.Schedule the shutdown of the default executor.TN)targetr)rrri threadingThread _do_shutdownstartjoin)rkfuturethreadrrrshutdown_default_executor1s  z'BaseEventLoop.shutdown_default_executorc CsXz |jjdd||jdWn2tyR}z||j|WYd}~n d}~00dS)NTwait)rshutdownrryrru)rkr exrrrr >s zBaseEventLoop._do_shutdowncCs(|rtdtdur$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrrrZ_get_running_looprwrrr_check_runningEs  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dzJt |||jrLq^qLWd|_d|_t d|dtj |n,d|_d|_t d|dtj |0dS)zRun until stop() is called.) firstiter finalizerFN)rr_set_coroutine_origin_tracking_debugr get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrZ_set_running_loop _run_oncer)rkZold_agen_hooksrrr run_foreverLs.        zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tzFz | Wn*|rp| rp| sp| Yn0W| tn | t0| std|S)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. rFz+Event loop stopped before Future completed.)rrrZisfuturer Z ensure_futureZ_log_destroy_pendingadd_done_callbackr[rrrTrUZremove_done_callbackrrr)rkr Znew_taskrrrrun_until_completecs"     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)rrwrrrrXszBaseEventLoop.stopcCsp|rtd|jrdS|jr,td|d|_|j|jd|_ |j }|durld|_ |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 %rTFr) rrrrrrdebugrrrrrrrkexecutorrrrrs   zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rrwrrrrszBaseEventLoop.is_closedcCs0|s,|d|t|d|s,|dS)Nzunclosed event loop r)rrrr)rk_warnrrr__del__szBaseEventLoop.__del__cCs |jduS)z*Returns True if the event loop is running.N)rrwrrrrszBaseEventLoop.is_runningcCstS)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. )rrrwrrrrszBaseEventLoop.time)contextcGs4|j|||g|Rd|i}|jr0|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. r%r)call_atrr)rkdelaycallbackr%rtimerrrr call_laters zBaseEventLoop.call_latercGsZ||jr"|||dt|||||}|jrB|jd=t|j |d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. r&rT) rr _check_thread_check_callbackr TimerHandlerheapqheappushr)rkwhenr(r%rr)rrrr&s zBaseEventLoop.call_atcGsB||jr"|||d||||}|jr>|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_soonr)rrr+r, _call_soonrrkr(r%rrrrrr1s  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr8r)rkr(methodrrrr,s  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rHandlerrr<)rkr(rr%rrrrr2s  zBaseEventLoop._call_sooncCs,|jdurdSt}||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)rrrrr)rkZ thread_idrrrr+ s  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrr,r2rrr3rrrrs z"BaseEventLoop.call_soon_threadsafecGsh||jr||d|durL|j}||durLtjjdd}||_tj|j |g|R|dS)Nrun_in_executorZasyncio)Zthread_name_prefixr) rrr,rr concurrentrThreadPoolExecutorZ wrap_futuresubmit)rkr"funcrrrrr6%s zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rr7rr8rrDeprecationWarningrr!rrrset_default_executor5s z"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r<r rr rr& getaddrinforinfo) rkr>r?r@rArBflagsmsgt0addrinfodtrrr_getaddrinfo_debug>s&      z BaseEventLoop._getaddrinfo_debugrr@rArBrBc s2|jr|j}ntj}|d|||||||IdHSrE)rrGr&r@r6)rkr>r?r@rArBrBZ getaddr_funcrrrr@Vs zBaseEventLoop.getaddrinfocs|dtj||IdHSrE)r6r& getnameinfo)rkZsockaddrrBrrrrI`s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtdt||||||z|||||IdHWStjyv}z|sbWYd}~n d}~00|||||IdHS)Nrzthe socket must be non-blocking) r gettimeoutr'r`_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rkr,fileoffsetcountrJrZrrr sock_sendfileds zBaseEventLoop.sock_sendfilecstd|d|ddS)Nz-syscall sendfile is not available for socket z and file z combinationrrNrkr,rPrQrRrrrrMss z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}z|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq|||d| IdH|| 7}q2|W|dkrt |dr|||Sn&|dkrt |dr|||0dS)Nrseek) rVminrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearray memoryviewr6readintoZ sock_sendallr%) rkr,rPrQrR blocksizebuf total_sentviewreadrrrrOzs6  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddvrtd|jtjks,td|durbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)Nbmodez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r})) rr'rAr&r4rr7r8formatrUrrrrLs2   z$BaseEventLoop._check_sendfile_paramsc sDg}|||\}}}}} d} ztj|||d} | d|dur|D]t\}}}}} z| | WqWqHty} z8d| d| j} t| j| } || WYd} ~ qHd} ~ 00qH|| | | IdH| WSty } z*|| | dur | WYd} ~ n(d} ~ 0| dur8| Yn0dS)z$Create, bind and connect one socket.Nr@rArBFz*error while attempting to bind on address : ) r<r& setblockingbindr*strerrorlowererrnopop sock_connectr)rkrZ addr_infoZlocal_addr_infosZ my_exceptionsr@type_rB_rr,laddrrZrCrrr _connect_socksB     "   zBaseEventLoop._connect_sock) r_r@rBrBr, local_addrrrhappy_eyeballs_delay interleavec  sz| dur|std| dur0|r0|s,td|} | durD|sDtd|durTt|| durh| durhd} |dusz|dur|durtdj||f|tj||dIdH}|std| durj| |tj||dIdHstdnd| rt|| }g| durV|D]B}z |IdH}WqWntyNYqYn0qn.tj fd d |D| d IdH\}}}|dur.d d Dt dkrdnJt dt fdd Drdtd ddd Dn.|durtd|jtjkr.td|j|||| | dIdH\}}jrr|d}td|||||||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 host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer@rArBrBr!getaddrinfo() returned empty listc3s |]}tj|VqdSrE) functoolspartialro)rFrE)r laddr_infosrkrrrH!sz2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rFsubrZrrrr'r/z3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrErrFrZ)modelrrrH-r/zMultiple exceptions: {}r?css|]}t|VqdSrEr{r|rrrrH2r/z5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr&z%r connected to %s:%r: (%r, %r))r'r`_ensure_resolvedr&r4r*rSror Zstaggered_racerrallrbr rA_create_connection_transportrget_extra_inforr )rkrr>r?r_r@rBrBr,rprrrqrrinfosrErmrsrr)rryr}rkrcreate_connections                zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| Yn0| |fS)NFrrr)rerirboolrrr) rkr,rr_rrrrrrrsrrrrMs" z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjur:td||tjjurz|||||IdHWStj y}z|svWYd}~n d}~00|std|| ||||IdHS)aSend a file to transport. Return the total number of bytes which were sent. The method uses high-performance os.sendfile if available. file must be a regular file object opened in binary mode. offset tells from where to start reading the file. If specified, count is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is updated on return or also in case of error in which case file.tell() can be used to figure out the number of bytes which were sent. fallback set to True makes asyncio to manually read and send the file when the platform does not support the sendfile syscall (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support sendfile syscall and fallback is False. zTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rnrrrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerrN_sendfile_fallback)rkrsrPrQrRrJrarZrrrsendfilegs4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedrT)rkrlrPrQrRrrrrszBaseEventLoop._sendfile_nativec s||r|||rt|dnd}t|}d}t|}z |rt|||}|dkr|W|dkrvt|drv||||IdHSt|d|} |d|j| IdH} | s|W|dkrt|dr||||IdHS| IdH| | d| || 7}q8W|dkr4t|dr4||||IdHn4|dkrht|drh||||IdH0dS)Ni@rrV) rVrWrXrar%rrYr6rZrpwrite) rkrlrPrQrRr[r\r]rBr^r_rrrrs@   z BaseEventLoop._sendfile_fallbackrc stdurtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn,ty|| | Yn0|jS) zzUpgrade transport to TLS. Return a new transport that *protocol* should start using immediately. Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)r_rrrZ SSLContextr8rrir Z SSLProtocolrfrgr1rtr BaseExceptionrrZ_app_transport) rkrsrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlss>       zBaseEventLoop.start_tls)r@rBrB reuse_address reuse_portallow_broadcastr,c s| dur| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| d d} nss|d krtd ||fd ff}nttd r|tj krfD]}|durt |t st dqڈrxd dvrxz"t t jr.tWnFtyDYn4tyv}ztd|WYd}~n d}~00||ffff}ni}d fdffD]\}}|durt |trt|dkst d|j||tj|||dIdH}|std|D]:\}}}}}||f}||vr0ddg||<||||<qqfdd|D}|sjtdg}|tur|rtdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tjtj d| d r| !|r*| s&|"| |IdH|} Wn`tyn}z(| durP| #|$|WYd}~n.d}~0| dur| #Yn0qq|d |}|%}|&| || |}|j'rrt(d||nt)d||z|IdHWn|#Yn0||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rp remote_addrr@rBrBrrrr?css$|]\}}|r|d|VqdS)=Nr)rFkvrrrrHr/z9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrr;z2-tuple is expectedrurvcs8g|]0\}}r|ddusr,|ddus||fqS)rNrr)rFkeyZ addr_pairrprrrr&sz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.) stacklevelrcz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))*rAr&r5r'dictr itemsrer%rrrr8statS_ISSOCKosst_moderemoveFileNotFoundErrorr*rerrorrrr_unsetrrr<r-r(r) SO_BROADCASTrfrkrr<rirrrAr ) rkrrprr@rBrBrrrr,ZoptsZproblemsZr_addrZaddr_pairs_inforRerrZ addr_infosidxrZfamrmZprorrrZ local_addressZremote_addressrZrrrsrrrcreate_datagram_endpoints                  z&BaseEventLoop.create_datagram_endpointc s^|dd\}}t|||||g|ddR} | dur>| gS|j||||||dIdHSdS)Nr;rH)rDr@) rkrr@rArBrBrr>r?rArrrrts  zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r@rArBrz getaddrinfo(z) returned empty list)rr&r4r*)rkr>r?r@rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor) r@rBr,rr_rrrrc  st|trtd| dur*|dur*td|dur:t||dusLdurL|dur\td| durxtjdkovtjdk} g} |dkrdg}n$t|t st|t j j s|g}n|}fdd |D}t j|d iIdH}ttj|}d }z8|D]}|\}}}}}zt|||}Wn6tjyVjrNtjd |||d dYqYn0| || rz|tjtjd | rt|tr|tjkrttdr|tj tj!d z|"|Wqt#y}z(t#|j$d||j%&fdWYd}~qd}~00qd }W|sJ| D]}|'qn|sH| D]}|'q80n4|dur^td|j(tj)krztd||g} | D]}|*d qt+| |||| }| r|,t -dIdHjrt.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 NoneNrsrtposixcygwinr0csg|]}j|dqS))r@rB)r)rFr>r@rBr?rkrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedr~rz %r is serving)/rrr8r'r`rrrplatformrrIabcIterabler rsetrNrOrPr&rrrwarningr<r(r) SO_REUSEADDRr-r;rr%r IPV6_V6ONLYrfr*rirgrhrrAr4rerrrrA)rkrr>r?r@rBr,rr_rrrrrZhostsfsrZ completedresrCsocktyperB canonnamesarrrrr create_servers          zBaseEventLoop.create_server)r_rcs|jtjkrtd||dur.|s.td|dur>t||j|||dd|dIdH\}}|jr~|d}t d|||||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. r~Nrsr0T)rrr&z%r handled: (%r, %r)) rAr&r4r'r`rrrrr )rkrr,r_rrsrrrrconnect_accepted_sockets    z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|Yn0|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rirrrrr filenorkrrrrrsrrrconnect_read_pipe s zBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|Yn0|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rirrrrr rrrrrconnect_write_pipe0s z BaseEventLoop.connect_write_pipecCs|g}|dur"|dt||durJ|tjkrJ|dt|n8|durf|dt||dur|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r<r#rr!rr r )rkrCrrrrArrr_log_subprocess@szBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| durZtd| durjtd|} d}|jrd |}||||||j| |d ||||fi| IdH}|jr|durtd |||| fS) Nzcmd must be a string universal_newlines must be Falsezshell must be Truerbufsize must be 0text must be Falseencoding must be Noneerrors must be Nonezrun shell command %rT%s: %r) rr6rr'rrrrrA)rkrcmdrrrrrrrrrrr debug_logrsrrrsubprocess_shellMs6 zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| durDtd| durTtd|f| }|}d}|jrd|}||||||j||d ||||fi| IdH}|jr|durtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r'rrrrrA)rkrZprogramrrrrrrrrrrrZ popen_argsrrrsrrrsubprocess_execqs6    zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rrwrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs(|durt|std|||_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 )rr8r)rkhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dur6t|||jf}nd}d|vr`|jdur`|jjr`|jj|d<|g}t|D]}|dvr|qn||}|dkrd t|}d }|| 7}n2|dkrd t|}d }|| 7}nt |}| |d |qnt j d ||ddS)aEDefault 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. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rz!Unhandled exception in event looprUNFZsource_tracebackZhandle_traceback>rrUr0z+Object created at (most recent call last): z+Handle created at (most recent call last): rd r)getrA __traceback__rrsortedr  traceback format_listrstriprr<rr) rkr%rrUrZ log_linesrvaluetbrrrdefault_exception_handlers<   z'BaseEventLoop.default_exception_handlerc Cs|jdurRz||Wqttfy0YqtyNtjdddYq0nz|||WnttfyzYnrty}zZz|d||dWn6ttfyYn tytjdddYn0WYd}~n d}~00dS)aDCall 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; - 'task' (optional): Task 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 handlerTrz$Unhandled error in exception handler)rrUr%zeException in default exception handler while handling an unexpected error in custom exception handler)rrrVrWrrr)rkr%rZrrrrs4    z$BaseEventLoop.call_exception_handlercCs>t|tjsJd|jrdSt|tjr.J|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrr5 _cancelledr-rr<rkrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rrrrrr_timer_handle_cancelled!sz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsf                   ;   Do