B ú?ÂCúG;ã@s¬ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZy ddlZWnek rœdZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZd Zd ZdZe edƒZ!dZ"e#ƒZ$dd„Z%dd„Z&dd„Z'd%dd„Z(dd„Z)e edƒrjdd„Z*ndd„Z*Gdd „d ej+ƒZ,Gd!d"„d"ej-ƒZ.Gd#d$„d$ej/ƒZ0dS)&éNé)Ú constants)Ú coroutines)Úevents)Úfutures)Ú protocols)Ússlproto)Útasks)Ú transports)Úlogger)Ú BaseEventLoopédgà?ÚAF_INET6i€QcCs0|j}tt|ddƒtjƒr$t|jƒSt|ƒSdS)NÚ__self__)Z _callbackÚ isinstanceÚgetattrr ÚTaskÚreprrÚstr)ÚhandleÚcb©rú6/opt/alt/python37/lib/python3.7/asyncio/base_events.pyÚ_format_handleEs rcCs(|tjkrdS|tjkrdSt|ƒSdS)Nzz)Ú subprocessÚPIPEÚSTDOUTr)ÚfdrrrÚ _format_pipeNs   rcCsLttdƒstdƒ‚n4y| tjtjd¡Wntk rFtdƒ‚YnXdS)NÚ SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)ÚhasattrÚsocketÚ ValueErrorÚ setsockoptÚ SOL_SOCKETrÚOSError)ÚsockrrrÚ_set_reuseportWs   r'c CszttdƒsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nVt|tƒrz|dkrzd}n>t|tƒr’|dkr’d}n&y t |ƒ}Wnt t fk r¶dSX|tj krÜtj g}trâ| tj¡n|g}t|tƒrö| d¡}d|krdSxp|D]h}yJt ||¡trD|tjkrD|||d||||ffS|||d||ffSWntk rnYnXq WdS)NÚ inet_ptonróÚZidnaú%)r r!Ú IPPROTO_TCPZ IPPROTO_UDPÚ SOCK_STREAMÚ SOCK_DGRAMrÚbytesrÚintÚ TypeErrorr"Ú AF_UNSPECÚAF_INETÚ _HAS_IPv6ÚappendrÚdecoder(r%) ÚhostÚportÚfamilyÚtypeÚprotoZflowinfoZscopeidZafsÚafrrrÚ _ipaddr_infobsL           r=cCs:| ¡s(| ¡}t|tƒr(t|tƒs(dSt |¡ ¡dS)N)Ú cancelledÚ exceptionrÚ BaseExceptionÚ ExceptionrZ _get_loopÚstop)ÚfutÚexcrrrÚ_run_until_complete_cbs rEÚ TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<| tjtj d¡dS)Nr) r9r!r3rr:r-r;r,r#rF)r&rrrÚ _set_nodelay¨s  rGcCsdS)Nr)r&rrrrG®sc@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Ú_SendfileFallbackProtocolcCsht|tjƒstdƒ‚||_| ¡|_| ¡|_|j |_ |  ¡|  |¡|j r^|jj  ¡|_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr1Ú _transportZ get_protocolÚ_protoZ is_readingÚ_should_resume_readingZ_protocol_pausedÚ_should_resume_writingÚ pause_readingÚ set_protocolÚ_loopÚ create_futureÚ_write_ready_fut)ÚselfÚtransprrrÚ__init__³s    z"_SendfileFallbackProtocol.__init__cÃs2|j ¡rtdƒ‚|j}|dkr$dS|IdHdS)NzConnection closed by peer)rIÚ is_closingÚConnectionErrorrQ)rRrCrrrÚdrainÁs  z_SendfileFallbackProtocol.draincCs tdƒ‚dS)Nz?Invalid state: connection should have been established already.)Ú RuntimeError)rRÚ transportrrrÚconnection_madeÉsz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|j tdƒ¡n |j |¡|j |¡dS)NzConnection is closed by peer)rQZ set_exceptionrVrJÚconnection_lost)rRrDrrrr[Ís    z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj ¡|_dS)N)rQrIrOrP)rRrrrÚ pause_writingØs z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|j d¡d|_dS)NF)rQÚ set_result)rRrrrÚresume_writingÝs  z(_SendfileFallbackProtocol.resume_writingcCs tdƒ‚dS)Nz'Invalid state: reading should be paused)rX)rRÚdatarrrÚ data_receivedãsz'_SendfileFallbackProtocol.data_receivedcCs tdƒ‚dS)Nz'Invalid state: reading should be paused)rX)rRrrrÚ eof_receivedæsz&_SendfileFallbackProtocol.eof_receivedcÃsF|j |j¡|jr|j ¡|jdk r2|j ¡|jrB|j ¡dS)N) rIrNrJrKÚresume_readingrQÚcancelrLr^)rRrrrÚrestoreés   z!_SendfileFallbackProtocol.restoreN) Ú__name__Ú __module__Ú __qualname__rTrWrZr[r\r^r`rardrrrrrH²s rHc@sxeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z e dd„ƒZ dd„Z dd„Zdd„Zdd„ZdS)ÚServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rOÚ_socketsÚ _active_countÚ_waitersÚ_protocol_factoryÚ_backlogÚ _ssl_contextÚ_ssl_handshake_timeoutÚ_servingÚ_serving_forever_fut)rRÚloopÚsocketsÚprotocol_factoryZ ssl_contextÚbacklogÚssl_handshake_timeoutrrrrTøszServer.__init__cCsd|jj›d|j›dS)Nú)Ú __class__rers)rRrrrÚ__repr__szServer.__repr__cCs|jd7_dS)Nr)rj)rRrrrÚ_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*| ¡dS)Nrr)rjriÚ_wakeup)rRrrrÚ_detach szServer._detachcCs0|j}d|_x|D]}| ¡s| |¡qWdS)N)rkÚdoner])rRÚwaitersÚwaiterrrrr|s  zServer._wakeupc CsN|jr dSd|_x8|jD].}| |j¡|j |j||j||j|j¡qWdS)NT) rpriZlistenrmrOÚ_start_servingrlrnro)rRr&rrrrs   zServer._start_servingcCs|jS)N)rO)rRrrrÚget_loop#szServer.get_loopcCs|jS)N)rp)rRrrrÚ is_serving&szServer.is_servingcCs|jdkrgSt|jƒS)N)riÚlist)rRrrrrs)s zServer.socketscCsr|j}|dkrdSd|_x|D]}|j |¡qWd|_|jdk r\|j ¡s\|j ¡d|_|jdkrn| ¡dS)NFr) rirOZ _stop_servingrprqr~rcrjr|)rRrsr&rrrÚclose/s     z Server.closecÃs"| ¡tjd|jdIdHdS)Nr)rr)rr ÚsleeprO)rRrrrÚ start_servingBszServer.start_servingc Ãs¢|jdk rtd|›dƒ‚|jdkr4td|›dƒ‚| ¡|j ¡|_zLy|jIdHWn6tjk rz| ¡|  ¡IdHWd‚XYnXWdd|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rqrXrirrOrPrZCancelledErrorr…Ú wait_closed)rRrrrÚ serve_foreverHs   zServer.serve_forevercÃs<|jdks|jdkrdS|j ¡}|j |¡|IdHdS)N)rirkrOrPr5)rRr€rrrrˆ]s   zServer.wait_closedN)rerfrgrTrzr{r}r|rr‚rƒÚpropertyrsr…r‡r‰rˆrrrrrhös   rhc @s*eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zdd d dœdd„Z dždd d d d ddœdd„Z dŸdd„Z d dd„Z d¡dd„Z d¢dd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zd4d5„Zd6d7„Zd8d9„Zd:d;„Zd d<œd=d>„Zd d<œd?d@„Zd d<œdAdB„Z dCdD„Z!dEdF„Z"dGdH„Z#d d<œdIdJ„Z$dKdL„Z%dMdN„Z&dOdP„Z'dQdQdQdQdRœdSdT„Z(d£dUdV„Z)d¤ddWœdXdY„Z*dZd[„Z+d\d]„Z,d^d_„Z-d¥d dQdQdQd d d d d`œdadb„Z.d¦dcdd„Z/d§ddWœdedf„Z0dgdh„Z1didj„Z2dd d dkœdldm„Z3d¨dQdQdQe4d d d dnœdodp„Z5dQe6j7dQdQdRœdqdr„Z8dsdt„Z9d©e6j:e6j;d dud d d d ddvœ dwdx„Zd~d„Z?d€d„Z@eAjBeAjBeAjBdddQd‚œdƒd„„ZCeAjBeAjBeAjBdddQd‚œd…d†„ZDd‡dˆ„ZEd‰dŠ„ZFd‹dŒ„ZGddŽ„ZHdd„ZId‘d’„ZJd“d”„ZKd•d–„ZLd—d˜„ZMd™dš„ZNd›dœ„ZOd S)ªr cCsˆd|_d|_d|_t ¡|_g|_d|_d|_d|_ t   d¡j |_ d|_| t ¡¡d|_d|_d|_d|_d|_t ¡|_d|_dS)NrFÚ monotonicgš™™™™™¹?)Ú_timer_cancelled_countÚ_closedÚ _stoppingÚ collectionsÚdequeÚ_readyÚ _scheduledÚ_default_executorZ _internal_fdsÚ _thread_idÚtimeZget_clock_infoZ resolutionÚ_clock_resolutionÚ_exception_handlerÚ set_debugrZ_is_debug_modeÚslow_callback_durationÚ_current_handleÚ _task_factoryÚ"_coroutine_origin_tracking_enabledÚ&_coroutine_origin_tracking_saved_depthÚweakrefZWeakSetÚ _asyncgensÚ_asyncgens_shutdown_called)rRrrrrTgs$  zBaseEventLoop.__init__c Cs.d|jj›d| ¡›d| ¡›d| ¡›d S)Nrwz running=z closed=z debug=rx)ryreÚ is_runningÚ is_closedÚ get_debug)rRrrrrzƒszBaseEventLoop.__repr__cCs tj|dS)N)rr)rZFuture)rRrrrrP‰szBaseEventLoop.create_futurecCs@| ¡|jdkr0tj||d}|jr<|jd=n | ||¡}|S)N)rréÿÿÿÿ)Ú _check_closedr›r rÚ_source_traceback)rRÚcoroZtaskrrrÚ create_tasks   zBaseEventLoop.create_taskcCs"|dk rt|ƒstdƒ‚||_dS)Nz'task factory must be a callable or None)Úcallabler1r›)rRÚfactoryrrrÚset_task_factory›s zBaseEventLoop.set_task_factorycCs|jS)N)r›)rRrrrÚget_task_factory©szBaseEventLoop.get_task_factoryN)ÚextraÚservercCst‚dS)N)ÚNotImplementedError)rRr&Úprotocolr€r­r®rrrÚ_make_socket_transport­sz$BaseEventLoop._make_socket_transportFT)Ú server_sideÚserver_hostnamer­r®rvÚcall_connection_madec Cst‚dS)N)r¯) rRZrawsockr°Ú sslcontextr€r²r³r­r®rvr´rrrÚ_make_ssl_transport²sz!BaseEventLoop._make_ssl_transportcCst‚dS)N)r¯)rRr&r°Úaddressr€r­rrrÚ_make_datagram_transport»sz&BaseEventLoop._make_datagram_transportcCst‚dS)N)r¯)rRÚpiper°r€r­rrrÚ_make_read_pipe_transportÀsz'BaseEventLoop._make_read_pipe_transportcCst‚dS)N)r¯)rRr¹r°r€r­rrrÚ_make_write_pipe_transportÅsz(BaseEventLoop._make_write_pipe_transportc Ëst‚dS)N)r¯) rRr°ÚargsÚshellÚstdinÚstdoutÚstderrÚbufsizer­ÚkwargsrrrÚ_make_subprocess_transportÊsz(BaseEventLoop._make_subprocess_transportcCst‚dS)N)r¯)rRrrrÚ_write_to_selfÐszBaseEventLoop._write_to_selfcCst‚dS)N)r¯)rRÚ event_listrrrÚ_process_eventsÙszBaseEventLoop._process_eventscCs|jrtdƒ‚dS)NzEvent loop is closed)rrX)rRrrrr¥ÝszBaseEventLoop._check_closedcCs*|j |¡| ¡s&| |j| ¡¡dS)N)rŸÚdiscardr¢Úcall_soon_threadsafer¨Úaclose)rRÚagenrrrÚ_asyncgen_finalizer_hookás z&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|›dt|d|j |¡dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call)Úsource)r ÚwarningsÚwarnÚResourceWarningrŸÚadd)rRrÊrrrÚ_asyncgen_firstiter_hookæs   z&BaseEventLoop._asyncgen_firstiter_hookcÃsˆd|_t|jƒsdSt|jƒ}|j ¡tjdd„|Dƒd|dœŽIdH}x8t||ƒD]*\}}t|t ƒrV|  d|›||dœ¡qVWdS)NTcSsg|] }| ¡‘qSr)rÉ)Ú.0Zagrrrú üsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrrz;an error occurred during closing of asynchronous generator )Úmessager?Zasyncgen) r ÚlenrŸr„Úclearr ÚgatherÚziprrAÚcall_exception_handler)rRZ closing_agensÚresultsÚresultrÊrrrÚshutdown_asyncgensïs     z BaseEventLoop.shutdown_asyncgenscCs(| ¡rtdƒ‚t ¡dk r$tdƒ‚dS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)r¡rXrZ_get_running_loop)rRrrrÚ_check_runnung s  zBaseEventLoop._check_runnungc Cs–| ¡| ¡| |j¡t ¡|_t ¡}tj |j |j dz$t   |¡x| ¡|jrNPqNWWdd|_d|_t   d¡| d¡tj |ŽXdS)N)Ú firstiterÚ finalizerF)r¥rÝÚ_set_coroutine_origin_trackingÚ_debugÚ threadingÚ get_identr”ÚsysÚget_asyncgen_hooksÚset_asyncgen_hooksrÑrËrZ_set_running_loopÚ _run_oncerŽ)rRZold_agen_hooksrrrÚ run_forevers$       zBaseEventLoop.run_foreverc Cs | ¡| ¡t |¡ }tj||d}|r4d|_| t¡zr?Zremove_done_callbackrXrÛ)rRZfutureZnew_taskrrrÚrun_until_complete's"      z BaseEventLoop.run_until_completecCs d|_dS)NT)rŽ)rRrrrrBMszBaseEventLoop.stopcCsj| ¡rtdƒ‚|jrdS|jr,t d|¡d|_|j ¡|j ¡|j }|dk rfd|_ |j dddS)Nz!Cannot close a running event loopzClose %rTF)Úwait) r¡rXrrár Údebugr‘rÖr’r“Zshutdown)rRÚexecutorrrrr…Us   zBaseEventLoop.closecCs|jS)N)r)rRrrrr¢kszBaseEventLoop.is_closedcCs2| ¡s.tjd|›t|d| ¡s.| ¡dS)Nzunclosed event loop )rÌ)r¢rÍrÎrÏr¡r…)rRrrrÚ__del__os zBaseEventLoop.__del__cCs |jdk S)N)r”)rRrrrr¡vszBaseEventLoop.is_runningcCst ¡S)N)r•r‹)rRrrrr•zszBaseEventLoop.time)ÚcontextcGs2|j| ¡||f|žd|iŽ}|jr.|jd=|S)Nrîr¤)Úcall_atr•r¦)rRZdelayÚcallbackrîr¼ÚtimerrrrÚ call_laterƒs zBaseEventLoop.call_latercGsZ| ¡|jr"| ¡| |d¡t |||||¡}|jrB|jd=t |j |¡d|_ |S)Nrïr¤T) r¥ráÚ _check_threadÚ_check_callbackrZ TimerHandler¦ÚheapqÚheappushr’)rRÚwhenrðrîr¼rñrrrrï™s zBaseEventLoop.call_atcGsB| ¡|jr"| ¡| |d¡| |||¡}|jr>|jd=|S)NÚ call_soonr¤)r¥rárórôÚ _call_soonr¦)rRrðrîr¼rrrrrø©s  zBaseEventLoop.call_sooncCsDt |¡st |¡r$td|›dƒ‚t|ƒs@td|›d|›ƒ‚dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr1r©)rRrðÚmethodrrrrô¼s  zBaseEventLoop._check_callbackcCs.t ||||¡}|jr|jd=|j |¡|S)Nr¤)rZHandler¦r‘r5)rRrðr¼rîrrrrrùÆs  zBaseEventLoop._call_sooncCs,|jdkrdSt ¡}||jkr(tdƒ‚dS)NzMNon-thread-safe operation invoked on an event loop other than the current one)r”rârãrX)rRZ thread_idrrrróÍs  zBaseEventLoop._check_threadcGsB| ¡|jr| |d¡| |||¡}|jr6|jd=| ¡|S)NrÈr¤)r¥rárôrùr¦rÄ)rRrðrîr¼rrrrrÈÞs z"BaseEventLoop.call_soon_threadsafecGsZ| ¡|jr| |d¡|dkr@|j}|dkr@tj ¡}||_tj|j|f|žŽ|dS)NÚrun_in_executor)rr) r¥rárôr“Ú concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rRrìÚfuncr¼rrrrûés  zBaseEventLoop.run_in_executorcCs ||_dS)N)r“)rRrìrrrÚset_default_executorõsz"BaseEventLoop.set_default_executorc CsÞ|›d|›g}|r$| d|›¡|r8| d|›¡|rL| d|›¡|r`| d|›¡d |¡}t d|¡| ¡}t ||||||¡} | ¡|} d|›d | d d ›d | ›}| |jkrÐt |¡n t |¡| S) Nú:zfamily=ztype=zproto=zflags=z, zGet address info %szGetting address info z took g@@z.3fzms: ) r5Újoinr rër•r!Ú getaddrinfor™Úinfo) rRr7r8r9r:r;ÚflagsÚmsgÚt0ZaddrinfoÚdtrrrÚ_getaddrinfo_debugøs&      z BaseEventLoop._getaddrinfo_debugr)r9r:r;rc Ãs2|jr|j}ntj}| d|||||||¡IdHS)N)rárr!rrû)rRr7r8r9r:r;rZ getaddr_funcrrrrs zBaseEventLoop.getaddrinfocÃs| dtj||¡IdHS)N)rûr!Ú getnameinfo)rRZsockaddrrrrrrszBaseEventLoop.getnameinfo)Úfallbackc Ãs‚|jr| ¡dkrtdƒ‚| ||||¡y| ||||¡IdHStjk rj}z |sZ‚Wdd}~XYnX| ||||¡IdHS)Nrzthe socket must be non-blocking)ráZ gettimeoutr"Ú_check_sendfile_paramsÚ_sock_sendfile_nativerÚSendfileNotAvailableErrorÚ_sock_sendfile_fallback)rRr&ÚfileÚoffsetÚcountr rDrrrÚ sock_sendfileszBaseEventLoop.sock_sendfilecÃst d|›d¡‚dS)Nz-syscall sendfile is not available for socket z and file {file!r} combination)rr )rRr&rrrrrrr ,sz#BaseEventLoop._sock_sendfile_nativec ÃsÌ|r| |¡|rt|tjƒntj}t|ƒ}d}ztxn|rPt|||ƒ}|dkrPPt|ƒd|…}| d|j|¡IdH} | s|P| ||d| …¡IdH|| 7}q4W|S|dkrÆt |dƒrÆ| ||¡XdS)NrÚseek) rÚminrZ!SENDFILE_FALLBACK_READBUFFER_SIZEÚ bytearrayÚ memoryviewrûÚreadintoZ sock_sendallr ) rRr&rrrÚ blocksizeÚbufÚ total_sentÚviewÚreadrrrr 3s(  z%BaseEventLoop._sock_sendfile_fallbackcCs”dt|ddƒkrtdƒ‚|jtjks,tdƒ‚|dk rbt|tƒsLtd |¡ƒ‚|dkrbtd |¡ƒ‚t|tƒsztd |¡ƒ‚|dkrtd |¡ƒ‚dS)NÚbÚmodez$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"r:r!r-rr0r1Úformat)rRr&rrrrrrr Ms&     z$BaseEventLoop._check_sendfile_params)Ússlr9r;rr&Ú local_addrr³rvc ƒs| dk r|stdƒ‚| dkr0|r0|s,tdƒ‚|} | dk rD|sDtdƒ‚|dk sV|dk r†|dk rftdƒ‚|j||f|tj|||dIdH} | s”tdƒ‚| dk rÆ|j| |tj|||dIdH} | sÆtdƒ‚g}xæ| D]J\}}}}}yÚtj|||d}| d¡| dk r’xˆ| D]r\}}}}}y| |¡PWnPtk r|}z0d |›d |j ¡›}t|j |ƒ}|  |¡Wdd}~XYnXqW|  ¡d}wÒ|j r¨t  d ||¡| ||¡IdHWn^tk rü}z |dk râ|  ¡|  |¡Wdd}~XYqÒ|dk r|  ¡‚YqÒXPqÒWt|ƒd kr:|d ‚nJt|d ƒ‰t‡fdd„|Dƒƒrf|d ‚td d dd„|Dƒ¡¡ƒ‚n.|dkr˜tdƒ‚|jtjkr´td|›ƒ‚|j|||| | dIdH\}}|j rø| d¡}t  d|||||¡||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz1ssl_handshake_timeout is only meaningful with sslz8host/port and sock can not be specified at the same time)r9r:r;rrrz!getaddrinfo() returned empty list)r9r:r;Fz*error while attempting to bind on address z: zconnect %r to %rrrc3s|]}t|ƒˆkVqdS)N)r)rÒrD)Úmodelrrú Æsz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|ƒVqdS)N)r)rÒrDrrrr"Ësz5host and port was not specified and no sock specifiedz"A Stream Socket was expected, got )rvr!z%r connected to %s:%r: (%r, %r))r"Ú_ensure_resolvedr!r-r%Ú setblockingÚbindÚstrerrorÚlowerÚerrnor5r…rár rëÚ sock_connectrÕrÚallrrr:Ú_create_connection_transportÚget_extra_info)rRrtr7r8rr9r;rr&r r³rvÚinfosZ laddr_infosÚ exceptionsr:Zcnamer·Ú_ZladdrrDrrYr°r)r!rÚcreate_connectionbs–       "       zBaseEventLoop.create_connectionc Ãs„| d¡|ƒ}| ¡}|rHt|tƒr*dn|} |j||| ||||d} n| |||¡} y|IdHWn|  ¡‚YnX| |fS)NF)r²r³rv)r$rPrÚboolr¶r±r…) rRr&rtrr³r²rvr°r€rµrYrrrr+æs   z*BaseEventLoop._create_connection_transportc Ãs°| ¡rtdƒ‚t|dtjjƒ}|tjjkr:td|›ƒ‚|tjjkrˆy| ||||¡IdHStj k r†}z |sv‚Wdd}~XYnX|sštd|›ƒ‚|  ||||¡IdHS)NzTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport ) rUrXrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVEÚ_sendfile_nativerr Ú_sendfile_fallback)rRrYrrrr rrDrrrÚsendfiles&     zBaseEventLoop.sendfilecÃst d¡‚dS)Nz!sendfile syscall is not supported)rr )rRrSrrrrrrr2/szBaseEventLoop._sendfile_nativec Ãsè|r| |¡|rt|dƒnd}t|ƒ}d}t|ƒ}z~xx|rVt|||ƒ}|dkrV|St|ƒd|…} | d|j| ¡IdH} | s„|S| ¡IdH| | d| …¡|| 7}q8WWd|dkrÔt |dƒrÔ| ||¡|  ¡IdHXdS)Ni@rr) rrrrHrrûrrWÚwriter rd) rRrSrrrrrrr;rrrrrr33s, z BaseEventLoop._sendfile_fallback)r²r³rvc ÃsØtdkrtdƒ‚t|tjƒs*td|›ƒ‚t|ddƒsFtd|›dƒ‚| ¡}tj|||||||dd}|  ¡|  |¡|  |j |¡} |  |j ¡} y|IdHWn.tk rÐ| ¡|  ¡|  ¡‚YnX|jS)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())rvr´)rrXrZ SSLContextr1rrPrZ SSLProtocolrMrNrørZrbrAr…rcZ_app_transport) rRrYr°rµr²r³rvr€Z ssl_protocolZ conmade_cbZ resume_cbrrrÚ start_tlsLs4      zBaseEventLoop.start_tls)r9r;rÚ reuse_addressÚ reuse_portÚallow_broadcastr&c ƒsŽ| dk r| jtjkr"td| ›ƒ‚ˆs>ˆs>|s>|s>|s>|s>| r~tˆˆ|||||| d} d dd„|  ¡Dƒ¡} td| ›dƒ‚|  d¡d} n€ˆsºˆsº|d kr¨td ƒ‚||fd ff}n ttd ƒr|tj krx*ˆˆfD]}|dk rÜt |t ƒsÜt d ƒ‚qÜW||fˆˆfff}nÈt  ¡}x˜d ˆfdˆffD]„\}}|dk r,|j||tj|||dIdH}|sjtdƒ‚xB|D]:\}}}}}||f}||krœddg||<||||<qpWq,W‡‡fdd„| ¡Dƒ}|sÚtdƒ‚g}|tk r|røtdƒ‚ntjdtddx|D]ô\\}}\}}d} d} yxtj|tj|d} |rJt| ƒ| rb|  tjtjd¡|  d¡ˆr||  |¡ˆrž| sš| | |¡IdH|} Wn^tk rà}z | dk rÆ|  ¡| |¡Wdd}~XYn"| dk rø|  ¡‚YnXPqW|d ‚|ƒ}| ¡}| | || |¡}|jr`ˆrPt  !dˆˆ||¡nt  "dˆ||¡y|IdHWn| ¡‚YnX||fS)NzA UDP Socket was expected, got )r Ú remote_addrr9r;rr7r8r9z, css$|]\}}|r|›d|›VqdS)ú=Nr)rÒÚkÚvrrrr"Œsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. (ú)Frzunexpected address family)NNÚAF_UNIXzstring is expectedr)r9r:r;rrrz!getaddrinfo() returned empty listcs8g|]0\}}ˆr|ddksˆr,|ddks||f‘qS)rNrr)rÒÚkeyZ addr_pair)r r:rrrÓ³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.zcThe *reuse_address* parameter has been deprecated as of 3.7.6 and is scheduled for removal in 3.11.é)Ú stacklevel)r9r:r;z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))#r:r!r.r"ÚdictrÚitemsr$r r?rrr1rÚ OrderedDictr#r%Ú_unsetrÍrÎÚDeprecationWarningr'r#r$Z SO_BROADCASTr%r)r…r5rPr¸rár rrë)rRrtr r:r9r;rr7r8r9r&ZoptsZproblemsZr_addrZaddr_pairs_infoZaddrZ addr_infosÚidxr-Zfamr/Zpror·r@r.Z local_addressZremote_addressrDr°r€rYr)r r:rÚcreate_datagram_endpointzs¼                z&BaseEventLoop.create_datagram_endpointc Ãs\|dd…\}}t|||||f|dd…žŽ} | dk r<| gS|j||||||dIdHSdS)NrA)r9r:r;r)r=r) rRr·r9r:r;rrrr7r8rrrrr#s  zBaseEventLoop._ensure_resolvedcÃs8|j||f|tj||dIdH}|s4td|›dƒ‚|S)N)r9r:rrrz getaddrinfo(z) returned empty list)r#r!r-r%)rRr7r8r9rr-rrrÚ_create_server_getaddrinfo s  z(BaseEventLoop._create_server_getaddrinfor ) r9rr&rurr7r8rvr‡c  ƒsÄt|tƒrtdƒ‚| dk r*|dkr*tdƒ‚|dk s<ˆdk r*|dk rLtdƒ‚| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tƒs”t|t j j ƒsœ|g}n|}‡‡‡‡fdd„|Dƒ}t j |d ˆiŽIdH}ttj |¡ƒ}d }z"x|D] }|\}}}}}yt |||¡}Wn6tjk rJˆjrDtjd |||d d wîYnX|  |¡| rn| tjtjd ¡| r|t|ƒtr¬|tjkr¬ttdƒr¬| tjtj d ¡y| !|¡Wqît"k rú}z t"|j#d||j$ %¡fƒd‚Wdd}~XYqîXqîWd }Wd|s&x| D]}| &¡qWXn4|dkr.rrFz:create_server() failed to create socket.socket(%r, %r, %r)T)Úexc_infoÚ IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz"A Stream Socket was expected, got r)rrz %r is serving).rr1r1r"ÚosÚnameräÚplatformrrÚabcÚIterabler r×ÚsetÚ itertoolsÚchainÚ from_iterabler!Úerrorrár Úwarningr5r#r$Z SO_REUSEADDRr'r4rr rNZ IPV6_V6ONLYr%r%r(r&r'r…r:r-r$rhrr†r)rRrtr7r8r9rr&rurr7r8rvr‡rsZhostsZfsr-Z completedZresr<Zsocktyper;Z canonnameZsaÚerrr®r)r9rr8rRrÚ create_serversŠ     *     zBaseEventLoop.create_server)rrvcÃsv|jtjkrtd|›ƒ‚|dk r.|s.tdƒ‚|j|||dd|dIdH\}}|jrn| d¡}t d|||¡||fS)Nz"A Stream Socket was expected, got z1ssl_handshake_timeout is only meaningful with sslr*T)r²rvr!z%r handled: (%r, %r)) r:r!r-r"r+rár,r rë)rRrtr&rrvrYr°rrrÚconnect_accepted_socket‰s    z%BaseEventLoop.connect_accepted_socketcÃsd|ƒ}| ¡}| |||¡}y|IdHWn| ¡‚YnX|jr\t d| ¡||¡||fS)Nz Read pipe %r connected: (%r, %r))rPrºr…rár rëÚfileno)rRrtr¹r°r€rYrrrÚconnect_read_pipe¦szBaseEventLoop.connect_read_pipecÃsd|ƒ}| ¡}| |||¡}y|IdHWn| ¡‚YnX|jr\t d| ¡||¡||fS)Nz!Write pipe %r connected: (%r, %r))rPr»r…rár rër])rRrtr¹r°r€rYrrrÚconnect_write_pipe¶sz BaseEventLoop.connect_write_pipecCs–|g}|dk r"| dt|ƒ›¡|dk rJ|tjkrJ| dt|ƒ›¡n8|dk rf| dt|ƒ›¡|dk r‚| dt|ƒ›¡t d |¡¡dS)Nzstdin=zstdout=stderr=zstdout=zstderr=ú )r5rrrr rër)rRrr¾r¿rÀrrrrÚ_log_subprocessÆszBaseEventLoop._log_subprocess)r¾r¿rÀÚuniversal_newlinesr½rÁc Ësªt|ttfƒstdƒ‚|r"tdƒ‚|s.tdƒ‚|dkr>tdƒ‚|ƒ} d} |jrfd|} | | |||¡|j| |d||||f| ŽIdH} |jr¢| dk r¢t d| | ¡| | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr/rr"rárarÃr r) rRrtÚcmdr¾r¿rÀrbr½rÁrÂr°Ú debug_logrYrrrÚsubprocess_shellÓs$zBaseEventLoop.subprocess_shellcÏsÐ|r tdƒ‚|rtdƒ‚|dkr(tdƒ‚|f| } x.| D]&} t| ttfƒs8tdt| ƒj›ƒ‚q8W|ƒ} d}|jrŒd|›}| ||||¡|j | | d||||f| ŽIdH}|jrÈ|dk rÈt   d||¡|| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z6program arguments must be a bytes or text string, not zexecute program Fz%s: %r) r"rrr/r1r:rerárarÃr r)rRrtZprogramr¾r¿rÀrbr½rÁr¼rÂZ popen_argsÚargr°rdrYrrrÚsubprocess_execïs,    zBaseEventLoop.subprocess_execcCs|jS)N)r—)rRrrrÚget_exception_handler sz#BaseEventLoop.get_exception_handlercCs(|dk rt|ƒstd|›ƒ‚||_dS)Nz+A callable object or None is expected, got )r©r1r—)rRZhandlerrrrÚset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs| d¡}|sd}| d¡}|dk r6t|ƒ||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}x’t|ƒD]†}|dkr~qp||}|dkr°d t |¡¡}d }||  ¡7}n2|dkrÚd t |¡¡}d }||  ¡7}nt |ƒ}|  |›d |›¡qpWt j d  |¡|d dS)NrÔz!Unhandled exception in event loopr?FZsource_tracebackZhandle_traceback>r?rÔr*z+Object created at (most recent call last): z+Handle created at (most recent call last): z: Ú )rM)Úgetr:Ú __traceback__ršr¦ÚsortedrÚ tracebackÚ format_listÚrstriprr5r rX) rRrîrÔr?rMZ log_linesr@ÚvalueÚtbrrrÚdefault_exception_handler#s6    z'BaseEventLoop.default_exception_handlerc Cs°|jdkr>y| |¡Wq¬tk r:tjdddYq¬Xnny| ||¡Wn\tk rª}z>y| d||dœ¡Wn"tk r˜tjdddYnXWdd}~XYnXdS)Nz&Exception in default exception handlerT)rMz$Unhandled error in exception handler)rÔr?rîzeException in default exception handler while handling an unexpected error in custom exception handler)r—rsrAr rX)rRrîrDrrrrÙUs" z$BaseEventLoop.call_exception_handlercCs|jr dS|j |¡dS)N)Ú _cancelledr‘r5)rRrrrrÚ _add_callbackˆszBaseEventLoop._add_callbackcCs| |¡| ¡dS)N)rurÄ)rRrrrrÚ_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)r’rŒ)rRrrrrÚ_timer_handle_cancelled•sz%BaseEventLoop._timer_handle_cancelledc Csšt|jƒ}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,| |¡q,Wt |¡||_d|_n8x6|jrš|jdjrš|jd8_t  |j¡}d|_qfWd}|j s¬|j r²d}n*|jrÜ|jdj }t td|| ¡ƒtƒ}|jr”|dkr”| ¡}|j |¡}| ¡|}|dkr tj} ntj} t|ƒ} |dkrNt | d|d| ¡nD| rpt | d|d|d| ¡n"|dkr t | d|d|d¡n |j |¡}| |¡| ¡|j} xD|jrü|jd}|j | krÚPt  |j¡}d|_|j  |¡qºWt|j ƒ} xˆt| ƒD]|} |j  ¡}|jr,q|jr„zD||_| ¡}| ¡| ¡|}||jkrvt  d t!|ƒ|¡Wdd|_Xn| ¡qWd}dS) NFrrgð?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)"rÕr’Ú_MIN_SCHEDULED_TIMER_HANDLESrŒÚ%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrtr5rõÚheapifyÚheappopr‘rŽZ_whenrÚmaxr•ÚMAXIMUM_SELECT_TIMEOUTráZ _selectorZselectÚloggingÚINFOÚDEBUGr ÚlogrÆr–ÚrangeÚpopleftršZ_runr™rYr)rRZ sched_countZ new_scheduledrZtimeoutr÷rrÅrÚlevelZneventZend_timeZntodoÚirrrrçšsˆ                       zBaseEventLoop._run_oncecCsHt|ƒt|jƒkrdS|r2t ¡|_t tj¡n t |j¡||_dS)N)r1rœräÚ#get_coroutine_origin_tracking_depthrÚ#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH)rRÚenabledrrrràýs  z,BaseEventLoop._set_coroutine_origin_trackingcCs|jS)N)rá)rRrrrr£ szBaseEventLoop.get_debugcCs ||_| ¡r| |j|¡dS)N)rár¡rÈrà)rRrˆrrrr˜szBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)NN)FN)rN)NN)NN)PrerfrgrTrzrPr¨r«r¬r±r¶r¸rºr»rÃrÄrÆr¥rËrÑrÜrÝrèrérBr…r¢rír¡r•ròrïrørôrùrórÈrûrþrrrrr r r r0r+r4r2r3r6rFrIr!r-r#rJr2Z AI_PASSIVEr[r\r^r_rarrrergrhrirsrÙrurvrwrçràr£r˜rrrrr esØ      &       .,  l23cr )rr)1rZcollections.abcÚconcurrent.futuresrürõrUr~rOr!rrâr•rnrärÍržrÚ ImportErrorr*rrrrrrr r rr Ú__all__rxryr r4r}ÚobjectrFrrr'r=rErGZProtocolrHZAbstractServerrhZAbstractEventLoopr rrrrÚsX               ;  Do