3 \[@s|dddddddddd d d d d gZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddZ ddZd2ddZddZd3ddZGdddZGdddeZGd ddZGd!ddZGd"ddZGd#d$d$eZdaejZGd%d&d&ejZeZd'd Zd(d Zd)d*Z d+dZ!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'dS)4AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder &/usr/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)Ncss|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s8eZdZdZdd Zd d Zd d ZddZddZdS)r _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3 __slots__rSrYr[r\rer r r r!rbs   csteZdZddgZfddZfddZddZd d Zd d Zd dZ ddZ ddZ ddZ fddZ ZS)r _scheduled_whencs.tj||||jr|jd=||_d|_dS)NrFrT)superrSrLrirh)rPwhenrQr/rR)rUr r!rSs zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rjrYrJinsertri)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashri)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)ri)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)ri__eq__)rPrqr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)ri)rPrqr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rirs)rPrqr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrirHrIrJNotImplemented)rPrqr r r!rss      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rsrw)rPrqZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrjr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrSrYrprrrtrurvrsrxr\ __classcell__r r )rUr!rs  c@seZdZddZddZdS)rcCstS)N)rw)rPr r r!closeszAbstractServer.closecCstS)N)rw)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3r{r|r r r r!rsc @seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d#d#d#d$d%d&Zdgd'd(Zdhd)d#d#d#d)d)d)d*d+d,Zdiejejd)d-d)d)d)d.d/d0Zd)d)d)d1d2d3Zd)d-d)d4d5d6Zdjd#d#d#d)d)d)d)d7d8d9Zd:d;Zdd?d@Z"e j!e j!e j!d>dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5d)S)krcCstdS)N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)N)r})rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)N)r})rPr r r!stopszAbstractEventLoop.stopcCstdS)N)r})rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)N)r})rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)N)r})rPr r r!r{s zAbstractEventLoop.closecCstdS)N)r})rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)N)r})rPr^r r r!rysz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r})rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r})rPrkrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r})rPr r r!time"szAbstractEventLoop.timecCstdS)N)r})rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r})rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r})rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r})rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r})rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r})rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r})rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r}) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)N)r}) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r})rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)N)r})rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)N)r}) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)N)r})rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)N)r})rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r})rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r})rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r})rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r})rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r})rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r})rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r})rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r})rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r})rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r})rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r})rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r})rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r})rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r})rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r})rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r})rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r})rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r})rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r})rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r})rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)6r4rfr3r~rrrrr{rryrrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rsr   '!   c@s4eZdZddZddZddZddZd d Zd S) rcCstdS)N)r})rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)N)r})rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)N)r})rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)N)r})rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)N)r})rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN)r4rfr3rr r r r r r r r!rs  c@sBeZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)NT)rrrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)N) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rrlocalrrSrr r r r r r!r9s  rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)N)rrr r r r!rscCs|adS)N)r)Zpolicyr r r!rscCst}|dk r|StjS)N)rrr)Z current_loopr r r!rs cCstj|dS)N)rr )rRr r r!r scCs tjS)N)rr r r r r!r scCs tjS)N)rr r r r r!r scCs tj|S)N)rr )rr r r!r s)r2)NN)(__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sX    >8 5"7