a DOgSg@sndZdZddlZddlZddlZddlZddlZddlZddlm Z GdddZ Gdd d e Z Gd d d Z Gd d d Z GdddZGdddeZdaeZGdddejZeZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Z eZ!eZ"eZ#eZ$zdd*l%mZmZmZmZWne&yXYn0eZ'eZ(eZ)eZ*dS)+z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpersc@sFeZdZdZdZdddZddZdd Zd d Zd d Z ddZ dS)rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|durt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr%3/opt/alt/python39/lib64/python3.9/asyncio/events.py__init__s zHandle.__init__cCsl|jjg}|jr|d|jdur:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r infoframer%r%r& _repr_info.s    zHandle._repr_infocCs(|jdur|jS|}dd|S)Nz<{}> )rr1formatjoin)r r/r%r%r&__repr__:s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dS)NT)rrrreprrrrr r%r%r&cancel@s   z Handle.cancelcCs|jSN)rr7r%r%r&r(KszHandle.cancelledc Csz|jj|jg|jRWn|ttfy4Ynfty}zNt|j|j}d|}|||d}|j rx|j |d<|j |WYd}~n d}~00d}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr.rrcall_exception_handler)r exccbmsgr$r%r%r&_runNs"  "z Handle._run)N) r, __module__ __qualname____doc__ __slots__r'r1r5r8r(rDr%r%r%r&rs   rcszeZdZdZddgZdfdd ZfddZd d Zd d Zd dZ ddZ ddZ ddZ fddZ ddZZS)rz7Object returned by timed callback registration methods. _scheduled_whenNcs<|dus Jt|||||jr,|jd=||_d|_dS)Nr)F)superr'rrJrI)r whenr!r"r#r$r+r%r&r'gs  zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rKr1rinsertrJ)r r/posrMr%r&r1os zTimerHandle._repr_infocCs t|jSr9)hashrJr7r%r%r&__hash__uszTimerHandle.__hash__cCst|tr|j|jkStSr9 isinstancerrJNotImplementedr otherr%r%r&__lt__xs  zTimerHandle.__lt__cCs$t|tr |j|jkp||StSr9rTrrJ__eq__rUrVr%r%r&__le__}s zTimerHandle.__le__cCst|tr|j|jkStSr9rSrVr%r%r&__gt__s  zTimerHandle.__gt__cCs$t|tr |j|jkp||StSr9rYrVr%r%r&__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr9)rTrrJrrrrUrVr%r%r&rZs     zTimerHandle.__eq__cs |js|j|tdSr9)rr_timer_handle_cancelledrKr8r7rMr%r&r8s zTimerHandle.cancelcCs|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). )rJr7r%r%r&rLszTimerHandle.when)N)r,rErFrGrHr'r1rRrXr[r\r]rZr8rL __classcell__r%r%rMr&rbs  rc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rz,Abstract server returned by create_server().cCstdS)z5Stop serving. This leaves existing connections open.NNotImplementedErrorr7r%r%r&closeszAbstractServer.closecCstdS)z4Get the event loop the Server object is attached to.Nr`r7r%r%r&get_loopszAbstractServer.get_loopcCstdS)z3Return True if the server is accepting connections.Nr`r7r%r%r& is_servingszAbstractServer.is_servingcstdS)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. Nr`r7r%r%r& start_servingszAbstractServer.start_servingcstdS)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. Nr`r7r%r%r& serve_foreverszAbstractServer.serve_forevercstdS)z*Coroutine to wait until service is closed.Nr`r7r%r%r& wait_closedszAbstractServer.wait_closedcs|Sr9r%r7r%r%r& __aenter__szAbstractServer.__aenter__cs||IdHdSr9)rbrg)r rAr%r%r& __aexit__szAbstractServer.__aexit__N) r,rErFrGrbrcrdrerfrgrhrir%r%r%r&rsrc @sveZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddddZ ddddZddddZddZddZdd d!d"Zddd#d$Zd%d&Zd'd(Zd)d)d)d)d*d+d,Zdxd-d.Zdydd)d)d)ddddddd/ d0d1Zdzejejdd2ddddd3d4 d5d6Zd{d3d7d8d9Zd:ddd;dd?d@Zd}dd2ddd3dAdBdCZ d~d)d)d)dddddDdEdFZ!dGdHZ"dIdJZ#e$j%e$j%e$j%dKdLdMZ&e$j%e$j%e$j%dKdNdOZ'dPdQZ(dRdSZ)dTdUZ*dVdWZ+dXdYZ,dZd[Z-d\d]Z.d^d_Z/d`daZ0ddd7dbdcZ1dddeZ2dfdgZ3dhdiZ4djdkZ5dldmZ6dndoZ7dpdqZ8drdsZ9dtduZ:dvdwZ;dS)rzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.Nr`r7r%r%r& run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. Nr`)r Zfuturer%r%r&run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. Nr`r7r%r%r&stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.Nr`r7r%r%r& is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.Nr`r7r%r%r& is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. Nr`r7r%r%r&rbs zAbstractEventLoop.closecstdS)z,Shutdown all active asynchronous generators.Nr`r7r%r%r&shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscstdS)z.Schedule the shutdown of the default executor.Nr`r7r%r%r&shutdown_default_executorsz+AbstractEventLoop.shutdown_default_executorcCstdS)z3Notification that a TimerHandle has been cancelled.Nr`)r r;r%r%r&r^sz)AbstractEventLoop._timer_handle_cancelledN)r$cGs|jd|g|Rd|iS)Nrr$) call_laterr r!r$r"r%r%r& call_soonszAbstractEventLoop.call_sooncGstdSr9r`)r Zdelayr!r$r"r%r%r&rqszAbstractEventLoop.call_latercGstdSr9r`)r rLr!r$r"r%r%r&call_at szAbstractEventLoop.call_atcCstdSr9r`r7r%r%r&timeszAbstractEventLoop.timecCstdSr9r`r7r%r%r& create_futureszAbstractEventLoop.create_future)namecCstdSr9r`)r cororwr%r%r& create_taskszAbstractEventLoop.create_taskcGstdSr9r`rrr%r%r&call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr9r`)r executorfuncr"r%r%r&run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr9r`)r r{r%r%r&set_default_executor!sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr9r`)r hostportrrrrr%r%r& getaddrinfo&szAbstractEventLoop.getaddrinfocstdSr9r`)r Zsockaddrrr%r%r& getnameinfo*szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr9r`)r protocol_factoryrrrrrrrrrrrrr%r%r&create_connection-sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrrec stdS)adA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nr`) r rrrrrrrrrrrrer%r%r& create_server6s3zAbstractEventLoop.create_server)fallbackcstdS)zRSend a file through a transport. Return an amount of sent bytes. Nr`)r transportfileoffsetcountrr%r%r&sendfilekszAbstractEventLoop.sendfileF) server_siderrcstdS)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. Nr`)r rZprotocolZ sslcontextrrrr%r%r& start_tlsss zAbstractEventLoop.start_tls)rrrrcstdSr9r`)r rpathrrrrr%r%r&create_unix_connection~sz(AbstractEventLoop.create_unix_connection)rrrrrecstdS)aA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nr`)r rrrrrrrer%r%r&create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. Nr`) r rrZ remote_addrrrrrrrrr%r%r&create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.Nr`r rpiper%r%r&connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.Nr`rr%r%r&connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr9r`)r rcmdrrrkwargsr%r%r&subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr9r`)r rrrrr"rr%r%r&subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr9r`r fdr!r"r%r%r& add_readerszAbstractEventLoop.add_readercCstdSr9r`r rr%r%r& remove_readerszAbstractEventLoop.remove_readercGstdSr9r`rr%r%r& add_writerszAbstractEventLoop.add_writercCstdSr9r`rr%r%r& remove_writerszAbstractEventLoop.remove_writercstdSr9r`)r rnbytesr%r%r& sock_recvszAbstractEventLoop.sock_recvcstdSr9r`)r rZbufr%r%r&sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr9r`)r rdatar%r%r& sock_sendall szAbstractEventLoop.sock_sendallcstdSr9r`)r rZaddressr%r%r& sock_connectszAbstractEventLoop.sock_connectcstdSr9r`)r rr%r%r& sock_acceptszAbstractEventLoop.sock_acceptcstdSr9r`)r rrrrrr%r%r& sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr9r`)r sigr!r"r%r%r&add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr9r`)r rr%r%r&remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr9r`)r factoryr%r%r&set_task_factory"sz"AbstractEventLoop.set_task_factorycCstdSr9r`r7r%r%r&get_task_factory%sz"AbstractEventLoop.get_task_factorycCstdSr9r`r7r%r%r&get_exception_handler*sz'AbstractEventLoop.get_exception_handlercCstdSr9r`)r Zhandlerr%r%r&set_exception_handler-sz'AbstractEventLoop.set_exception_handlercCstdSr9r`r r$r%r%r&default_exception_handler0sz+AbstractEventLoop.default_exception_handlercCstdSr9r`rr%r%r&r@3sz(AbstractEventLoop.call_exception_handlercCstdSr9r`r7r%r%r&r8szAbstractEventLoop.get_debugcCstdSr9r`)r Zenabledr%r%r& set_debug;szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN)sV  J@*u"9