• File: base_events.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python37/lib64/python3.7/asyncio/__pycache__/base_events.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 47.38 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Lj@sdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZyddlZWnek
rdZYnXddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZd
ZdZdZ e!e	dZ"dZ#e$Z%ddZ&ddZ'ddZ(d&ddZ)ddZ*e!e	drnddZ+nddZ+Gd d!d!ej,Z-Gd"d#d#ej.Z/Gd$d%d%ej0Z1dS)'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)futures)	protocols)sslproto)tasks)
transports)logger)
BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z	_callback
isinstancegetattrr	Taskreprrstr)handlecbr8/opt/alt/python37/lib64/python3.7/asyncio/base_events.py_format_handleEs
rcCs(|tjkrdS|tjkrdSt|SdS)Nz<pipe>z<stdout>)
subprocessPIPESTDOUTr)fdrrr_format_pipeNs


rcCsLttdstdn4y|tjtjdWntk
rFtdYnXdS)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_reuseportWs

r'c		CszttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nVt|trz|dkrzd}n>t|tr|dkrd}n&yt	|}Wnt
tfk
rdSX|tjkrtj
g}tr|tjn|g}t|tr|d}d|krdSxp|D]h}yJt||trD|tjkrD|||d||||ffS|||d||ffSWntk
rnYnXq
WdS)N	inet_ptonrZidna%)r r!IPPROTO_TCPZIPPROTO_UDPSOCK_STREAM
SOCK_DGRAMrbytesrint	TypeErrorr"	AF_UNSPECAF_INET	_HAS_IPv6appendrdecoder(r%)	hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr_ipaddr_infobsL







r=cCs:|s(|}t|tr(t|ts(dSt|dS)N)	cancelled	exceptionr
BaseException	ExceptionrZ	_get_loopstop)futexcrrr_run_until_complete_cbs
rETCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj	ddS)Nr)
r9r!r3rr:r-r;r,r#rF)r&rrr_set_nodelaysrGcCsdS)Nr)r&rrrrGsc@sTeZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
ddZdS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|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)selftransprrr__init__s


z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)rI
is_closingConnectionErrorrQ)rRrCrrrdrains
z_SendfileFallbackProtocol.draincCstddS)Nz?Invalid state: connection should have been established already.)RuntimeError)rR	transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk	r0|dkr$|jtdn|j||j|dS)NzConnection is closed by peer)rQZ
set_exceptionrVrJconnection_lost)rRrDrrrr[s
z)_SendfileFallbackProtocol.connection_lostcCs |jdk	rdS|jj|_dS)N)rQrIrOrP)rRrrr
pause_writings
z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)rQ
set_result)rRrrrresume_writings
z(_SendfileFallbackProtocol.resume_writingcCstddS)Nz'Invalid state: reading should be paused)rX)rRdatarrr
data_receivedsz'_SendfileFallbackProtocol.data_receivedcCstddS)Nz'Invalid state: reading should be paused)rX)rRrrreof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk	r2|j|jrB|jdS)N)	rIrNrJrKresume_readingrQcancelrLr^)rRrrrrestores


z!_SendfileFallbackProtocol.restoreN)__name__
__module____qualname__rTrWrZr[r\r^r`rardrrrrrHsrHc@sxeZdZddZddZddZddZd	d
ZddZd
dZ	ddZ
eddZddZ
ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_	dS)NrF)
rO_sockets
_active_count_waiters_protocol_factory_backlog_ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rRloopsocketsprotocol_factoryZssl_contextbacklogssl_handshake_timeoutrrrrTszServer.__init__cCsd|jjd|jdS)N<z	 sockets=>)	__class__rers)rRrrr__repr__szServer.__repr__cCs |jdk	st|jd7_dS)Nr)riAssertionErrorrj)rRrrr_attachszServer._attachcCs<|jdkst|jd8_|jdkr8|jdkr8|dS)Nrr)rjr{ri_wakeup)rRrrr_detachszServer._detachcCs0|j}d|_x|D]}|s||qWdS)N)rkdoner])rRwaiterswaiterrrrr}s

zServer._wakeupc	CsN|jr
dSd|_x8|jD].}||j|j|j||j||j|jqWdS)NT)	rpriZlistenrmrO_start_servingrlrnro)rRr&rrrrs
zServer._start_servingcCs|jS)N)rO)rRrrrget_loop#szServer.get_loopcCs|jS)N)rp)rRrrr
is_serving&szServer.is_servingcCs|jdkrgSt|jS)N)rilist)rRrrrrs)s
zServer.socketscCsr|j}|dkrdSd|_x|D]}|j|qWd|_|jdk	r\|js\|jd|_|jdkrn|dS)NFr)	rirOZ
_stop_servingrprqrrcrjr})rRrsr&rrrclose/s




zServer.closecs"|tjd|jdIdHdS)Nr)rr)rr	sleeprO)rRrrr
start_servingBszServer.start_servingc	s|jdk	rtd|d|jdkr4td|d||j|_zLy|jIdHWn6tjk
rz||	IdHWdXYnXWdd|_XdS)Nzserver z, is already being awaited on serve_forever()z
 is closed)
rqrXrirrOrPrZCancelledErrorrwait_closed)rRrrr
serve_foreverHs

zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdS)N)rirkrOrPr5)rRrrrrr]s

zServer.wait_closedN)rerfrgrTrzr|r~r}rrrpropertyrsrrrrrrrrrhs

rhc@s*eZdZddZddZddZddZd	d
ZddZdd
d
dddZ	ddd
d
d
d
ddddZ
dddZdddZdddZ
dddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zd
d<d=d>Zd
d<d?d@Zd
d<dAdBZ dCdDZ!dEdFZ"dGdHZ#d
d<dIdJZ$dKdLZ%dMdNZ&dOdPZ'dQdQdQdQdRdSdTZ(ddUdVZ)dddWdXdYZ*dZd[Z+d\d]Z,d^d_Z-dd
dQdQdQd
d
d
d
d`dadbZ.ddcddZ/dddWdedfZ0dgdhZ1didjZ2dd
d
dkdldmZ3ddQdQdQe4d
d
d
dndodpZ5dQe6j7dQdQdRdqdrZ8dsdtZ9de6j:e6j;d
dud
d
d
d
ddv	dwdxZ<d
d
dydzd{Z=d|d}Z>d~dZ?ddZ@eAjBeAjBeAjBdddQdddZCeAjBeAjBeAjBdddQdddZDddZEddZFddZGddZHddZIddZJddZKddZLddZMddZNddZOd
S)rcCsd|_d|_d|_t|_g|_d|_d|_d|_	t
dj|_
d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF	monotonicg?)_timer_cancelled_count_closed	_stoppingcollectionsdeque_ready
_scheduled_default_executorZ
_internal_fds
_thread_idtimeZget_clock_infoZ
resolution_clock_resolution_exception_handler	set_debugrZ_is_debug_modeslow_callback_duration_current_handle
_task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet
_asyncgens_asyncgens_shutdown_called)rRrrrrTgs$

zBaseEventLoop.__init__c	Cs.d|jjd|d|d|d	S)Nrwz	 running=z closed=z debug=rx)ryre
is_running	is_closed	get_debug)rRrrrrzszBaseEventLoop.__repr__cCstj|dS)z,Create a Future object attached to the loop.)rr)rZFuture)rRrrrrPszBaseEventLoop.create_futurecCs@||jdkr0tj||d}|jr<|jd=n|||}|S)zDSchedule a coroutine object.

        Return a task object.
        N)rr)
_check_closedrr	r_source_traceback)rRcoroZtaskrrrcreate_tasks

zBaseEventLoop.create_taskcCs"|dk	rt|std||_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)callabler1r)rRfactoryrrrset_task_factorys
zBaseEventLoop.set_task_factorycCs|jS)z<Return a task factory, or None if the default one is in use.)r)rRrrrget_task_factoryszBaseEventLoop.get_task_factoryN)extraservercCstdS)zCreate socket transport.N)NotImplementedError)rRr&protocolrrrrrr_make_socket_transportsz$BaseEventLoop._make_socket_transportFT)server_sideserver_hostnamerrrvcall_connection_madecCstdS)zCreate SSL transport.N)r)rRZrawsockr
sslcontextrrrrrrvrrrr_make_ssl_transportsz!BaseEventLoop._make_ssl_transportcCstdS)zCreate datagram transport.N)r)rRr&raddressrrrrr_make_datagram_transportsz&BaseEventLoop._make_datagram_transportcCstdS)zCreate read pipe transport.N)r)rRpiperrrrrr_make_read_pipe_transportsz'BaseEventLoop._make_read_pipe_transportcCstdS)zCreate write pipe transport.N)r)rRrrrrrrr_make_write_pipe_transportsz(BaseEventLoop._make_write_pipe_transportc	
stdS)zCreate subprocess transport.N)r)
rRrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportsz(BaseEventLoop._make_subprocess_transportcCstdS)zWrite a byte to self-pipe, to wake up the event loop.

        This may be called from a different thread.

        The subclass is responsible for implementing the self-pipe.
        N)r)rRrrr_write_to_selfszBaseEventLoop._write_to_selfcCstdS)zProcess selector events.N)r)rR
event_listrrr_process_eventsszBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rrX)rRrrrrszBaseEventLoop._check_closedcCs*|j||s&||j|dS)N)rdiscardrcall_soon_threadsaferaclose)rRagenrrr_asyncgen_finalizer_hooksz&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|dt|d|j|dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() call)source)rwarningswarnResourceWarningradd)rRrrrr_asyncgen_firstiter_hooks


z&BaseEventLoop._asyncgen_firstiter_hookcsd|_t|jsdSt|j}|jtjdd|Dd|dIdH}x8t||D]*\}}t|t	rV|
d|||dqVWdS)z,Shutdown all active asynchronous generators.TNcSsg|]}|qSr)r).0Zagrrr
<listcomp>sz4BaseEventLoop.shutdown_asyncgens.<locals>.<listcomp>)Zreturn_exceptionsrrz;an error occurred during closing of asynchronous generator )messager?Zasyncgen)rlenrrclearr	gatherziprrAcall_exception_handler)rRZ
closing_agensZresultsresultrrrrshutdown_asyncgenss



z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk	r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrXrZ_get_running_loop)rRrrr_check_runnung	s
zBaseEventLoop._check_runnungc	Cs||||jt|_t}tj	|j
|jdz$t
|x||jrNPqNWWdd|_d|_t
d|dtj	|XdS)zRun until stop() is called.)	firstiter	finalizerNF)rr_set_coroutine_origin_tracking_debug	threading	get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrZ_set_running_loop	_run_oncer)rRZold_agen_hooksrrrrun_forevers$





zBaseEventLoop.run_foreverc	Cs||t|}tj||d}|r4d|_|tz<y|	Wn*|rp|
rp|sp|YnXWd|
tX|
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.
        )rrFNz+Event loop stopped before Future completed.)rrrZisfuturer	Z
ensure_futureZ_log_destroy_pendingZadd_done_callbackrErrr>r?Zremove_done_callbackrXr)rRZfutureZnew_taskrrrrun_until_complete's"
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)r)rRrrrrBMszBaseEventLoop.stopcCsj|rtd|jrdS|jr,td|d|_|j|j|j	}|dk	rfd|_	|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 %rTF)wait)rrXrrrdebugrrrrZshutdown)rRexecutorrrrrUs

zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)r)rRrrrrkszBaseEventLoop.is_closedcCs2|s.tjd|t|d|s.|dS)Nzunclosed event loop )r)rrrrrr)rRrrr__del__os
zBaseEventLoop.__del__cCs
|jdk	S)z*Returns True if the event loop is running.N)r)rRrrrrvszBaseEventLoop.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.
        )rr)rRrrrrzszBaseEventLoop.time)contextcGs2|j|||f|d|i}|jr.|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_atrr)rRZdelaycallbackrrtimerrrr
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.
        rrT)
rr
_check_thread_check_callbackrTimerHandlerheapqheappushr)rRwhenrrrrrrrrs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)rrrr
_call_soonr)rRrrrrrrrrs
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 )rZiscoroutineZiscoroutinefunctionr1r)rRrmethodrrrrs

zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rHandlerrr5)rRrrrrrrrrs
zBaseEventLoop._call_sooncCs,|jdkrdSt}||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)rrrrX)rRZ	thread_idrrrrs	

zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrrrrr)rRrrrrrrrrsz"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executor)rr)	rrrr
concurrentrZThreadPoolExecutorZwrap_futureZsubmit)rRrfuncrrrrrs
zBaseEventLoop.run_in_executorcCs
||_dS)N)r)rRrrrrset_default_executorsz"BaseEventLoop.set_default_executorcCs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||}	||}
d|d	|
d
dd|	}|
|jkrt|n
t||	S)
N:zfamily=ztype=zproto=zflags=z, zGet address info %szGetting address info z took g@@z.3fzms: )	r5joinrrrr!getaddrinforinfo)rRr7r8r9r:r;flagsmsgt0Zaddrinfodtrrr_getaddrinfo_debugs&


z BaseEventLoop._getaddrinfo_debugr)r9r:r;rc
s2|jr|j}ntj}|d|||||||IdHS)N)rr	r!rr)rRr7r8r9r:r;rZgetaddr_funcrrrrs
zBaseEventLoop.getaddrinfocs|dtj||IdHS)N)rr!getnameinfo)rRZsockaddrrrrrr
szBaseEventLoop.getnameinfo)fallbackc
s|jr|dkrtd|||||y|||||IdHStjk
rj}z
|sZWdd}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ
gettimeoutr"_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rRr&fileoffsetcountrrDrrr
sock_sendfileszBaseEventLoop.sock_sendfilecstd|ddS)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|tjntj}t|}d}ztxn|rPt|||}|dkrPPt|d|}|d|j|IdH}	|	s|P|||d|	IdH||	7}q4W|S|dkrt	|dr|||XdS)Nrseek)
rminrZ!SENDFILE_FALLBACK_READBUFFER_SIZE	bytearray
memoryviewrreadintoZsock_sendallr )
rRr&rrr	blocksizebuf
total_sentviewreadrrrr3s(
z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk	rbt|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"r:r!r-rr0r1format)rRr&rrrrrrrMs&

z$BaseEventLoop._check_sendfile_params)sslr9r;rr&
local_addrrrvcs|
dk	r|std|
dkr0|r0|s,td|}
|dk	rD|sDtd|dk	sV|dk	r|dk	rftd|j||f|tj|||dIdH}|std|	dk	r|j|	|tj|||dIdH}
|
stdg}x|D]J\}}}}}ytj|||d}|d	|	dk	rx|
D]r\}}}}}y||PWnPtk
r|}z0d
|d|j}t|j	|}|
|Wdd}~XYnXqW|d}w|jrt
d|||||IdHWn^tk
r}z |dk	r||
|Wdd}~XYq|dk	r|YqXPqWt|d
kr:|dnJt|dtfdd|Drf|dtdddd|Dn.|dkrtd|jtjkrtd||j||||
|dIdH\}}|jr|d}t
d|||||||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 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)rrD)modelrr	<genexpr>sz2BaseEventLoop.create_connection.<locals>.<genexpr>zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrDrrrr$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%setblockingbindstrerrorlowererrnor5rrrrsock_connectrrallr rr:_create_connection_transportget_extra_info)rRrtr7r8r!r9r;rr&r"rrvinfosZladdr_infos
exceptionsr:Zcnamer_ZladdrrDrrYrr)r#rcreate_connectionbs


"




zBaseEventLoop.create_connectionc	s|d|}|}|rHt|tr*dn|}	|j|||	||||d}
n||||}
y|IdHWn|
YnX|
|fS)NF)rrrv)r&rPrboolrrr)rRr&rtr!rrrvrrrrYrrrr-s 

z*BaseEventLoop._create_connection_transportc
s|rtdt|dtjj}|tjjkr:td||tjjkry|||||IdHStj	k
r}z
|svWdd}~XYnX|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 )rUrXrrZ
_SendfileModeZUNSUPPORTEDZ
TRY_NATIVE_sendfile_nativerr_sendfile_fallback)rRrYrrrrrrDrrrsendfiles&
zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supported)rr)rRrSrrrrrrr4/szBaseEventLoop._sendfile_nativec
s|r|||rt|dnd}t|}d}t|}z~xx|rVt|||}|dkrV|St|d|}	|d|j|	IdH}
|
s|S|IdH||	d|
||
7}q8WWd|dkrt	|dr||||
IdHXdS)Ni@rr)rrrrHrrrrWwriter rd)rRrSrrrrrrr;rrrrrr53s,
z BaseEventLoop._sendfile_fallback)rrrvc
stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}|	|
|||j|}	||j
}
y|IdHWn.tk
r||	|
YnX|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())rvr)r!rXrZ
SSLContextr1rrPrZSSLProtocolrMrNrrZrbrArrcZ_app_transport)rRrYrrrrrvrZssl_protocolZ
conmade_cbZ	resume_cbrrr	start_tlsLs4	
zBaseEventLoop.start_tls)r9r;r
reuse_address
reuse_portallow_broadcastr&cs|
dk	r|
jtjkr"td|
s>s>|s>|s>|s>|s>|	r~t||||||	d}ddd|D}td|d|
d	d}
nss|d
krtd||fdff}nBttd
r|tj	krx*fD]}|dk	rt
|tstdqW||ffff}nt
}xd
fdffD]\}}|dk	r,t
|trXt|dks`td|j||tj|||dIdH}|stdxB|D]:\}}}}}||f}||krddg||<||||<qWq,Wfdd|D}|stdg}|tk	r*|rtdntjdtddx|D]\\}}\}}d}
d}
yxtj|tj|d}
|rlt|
|	r|
tjtjd|
d	r|
|r|	s||
|IdH|}
Wn^tk
r}z |
dk	r|
||Wdd}~XYn"|
dk	r|
YnXPq2W|d
|}| }|!|
||
|}|j"rrrt#$d||nt#%d||y|IdHWn|YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )r"remote_addrr9r;rr9r:r;z, css$|]\}}|r|d|VqdS)=Nr)rkvrrrr$sz9BaseEventLoop.create_datagram_endpoint.<locals>.<genexpr>zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expectedrz2-tuple is expected)r9r:r;rrrz!getaddrinfo() returned empty listcs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rkeyZ	addr_pair)r"r<rrrsz:BaseEventLoop.create_datagram_endpoint.<locals>.<listcomp>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"dictritemsr&r rArrr1rOrderedDicttuplerr{r%r%_unsetrrDeprecationWarningr'r#r$ZSO_BROADCASTr'r+rr5rPrrrrr)rRrtr"r<r9r;rr9r:r;r&ZoptsZproblemsZr_addrZaddr_pairs_infoZaddrZ
addr_infosidxr/Zfamr1ZprorrCr0Z
local_addressZremote_addressrDrrrYr)r"r<rcreate_datagram_endpointzs









z&BaseEventLoop.create_datagram_endpointc
s\|dd\}}t|||||f|dd}	|	dk	r<|	gS|j||||||dIdHSdS)NrB)r9r:r;r)r=r)
rRrr9r:r;rrrr7r8rrrrr%szBaseEventLoop._ensure_resolvedcs8|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&rur!r9r:rvrc	st|trtd|dk	r*|dkr*td|dk	s<dk	r*|dk	rLtd|	dkrhtjdkoftjdk}	g}
|dkr|dg}n$t|tst|t	j
js|g}n|}fdd	|D}tj
|d
iIdH}ttj|}d}z"x|D]}|\}}}}}yt|||}Wn6tjk
rJjrDtjd|||d
dwYnX|
||	rn|tjtjd
|
r|t|tr|tjkrttdr|tjtj d
y|!|Wqt"k
r}z t"|j#d||j$%fdWdd}~XYqXqWd
}Wd|s&x|
D]}|&qWXn4|dkr<td|j'tj(krXtd||g}
x|
D]}|)dqdWt*|
||||}|r|+tj,ddIdHjrt-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 NoneNz1ssl_handshake_timeout is only meaningful with sslz8host/port and sock can not be specified at the same timeposixcygwinr*csg|]}j|dqS))r9r)rM)rr7)r9rr8rRrrrFsz/BaseEventLoop.create_server.<locals>.<listcomp>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).rr3r1r"osnamerplatformrrabcIterabler	rset	itertoolschain
from_iterabler!errorrrwarningr5r#r$ZSO_REUSEADDRr'r4rr rQZIPV6_V6ONLYr'r%r*r(r)rr:r-r&rhrrr)rRrtr7r8r9rr&rur!r9r:rvrrsZhostsZfsr/Z	completedZresr<Zsocktyper;Z	canonnameZsaerrrr)r9rr8rRr
create_servers


*



zBaseEventLoop.create_server)r!rvcsv|jtjkrtd||dk	r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||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 Nz1ssl_handshake_timeout is only meaningful with sslr*T)rrvr!z%r handled: (%r, %r))	r:r!r-r"r-rr.rr)rRrtr&r!rvrYrrrrconnect_accepted_sockets

z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}y|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rPrrrrrfileno)rRrtrrrrYrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}y|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rPrrrrrr`)rRrtrrrrYrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk	r"|dt||dk	rJ|tjkrJ|dt|n8|dk	rf|dt||dk	r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r5rrrrrr)rRrrrrrrrr_log_subprocessszBaseEventLoop._log_subprocess)rrruniversal_newlinesrrc
st|ttfstd|r"td|s.td|dkr>td|}
d}|jrfd|}||||||j|
|d||||f|	IdH}|jr|dk	rtd||||
fS)	Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r)	rr/rr"rrdrrr)
rRrtcmdrrrrerrrr	debug_logrYrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcs|rtd|rtd|dkr(td|f|	}x.|D]&}t|ttfs8tdt|jq8W|}
d}|jrd|}||||||j	|
|d||||f|
IdH}|jr|dk	rt
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:rerrdrrr)rRrtZprogramrrrrerrrrZ
popen_argsargrrgrYrrrsubprocess_execs,


zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use.
        )r)rRrrrget_exception_handler
sz#BaseEventLoop.get_exception_handlercCs(|dk	rt|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 )rr1r)rRZhandlerrrrset_exception_handlersz#BaseEventLoop.set_exception_handlerc	Cs|d}|sd}|d}|dk	r6t|||jf}nd}d|kr`|jdk	r`|jjr`|jj|d<|g}xt|D]}|dkr~qp||}|dkrd	t|}d
}||	7}n2|dkrd	t|}d}||	7}nt
|}||d|qpWt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 loopr?NFZsource_tracebackZhandle_traceback>r?rr*z+Object created at (most recent call last):
z+Handle created at (most recent call last):
z: 
)rP)getr:
__traceback__rrsortedr	tracebackformat_listrstriprr5rr[)	rRrrr?rPZ	log_linesrCvaluetbrrrdefault_exception_handler#s6


z'BaseEventLoop.default_exception_handlercCs|jdkr>y||Wqtk
r:tjdddYqXnny|||Wn\tk
r}z>y|d||dWn"tk
rtjdddYnXWdd}~XYnXdS)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 handlerT)rPz$Unhandled error in exception handler)rr?rzeException in default exception handler while handling an unexpected error in custom exception handler)rrvrArr[)rRrrDrrrrUs"
z$BaseEventLoop.call_exception_handlercCs>t|tjstd|jrdSt|tjr.t|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr{
_cancelledrrr5)rRrrrr
_add_callbacks
zBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rxr)rRrrrr_add_callback_signalsafes
z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rr)rRrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc	Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,||q,Wt|||_d|_n8x6|jr|jdjr|jd8_t	|j}d|_qfWd}|j
s|jrd}n*|jr|jdj}t
td||t}|jr|dkr|}|j|}||}|dkr tj}	ntj}	t|}
|dkrNt|	d|d|
nD|
rpt|	d|d|d|
n"|dkrt|	d	|d|dn|j|}||||j}xD|jr|jd}|j|krPt	|j}d|_|j
|qWt|j
}xt|D]|}
|j
}|jr,q|jrzD||_|}|||}||jkrvt d
t!||Wdd|_Xn|qWd}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)"rr_MIN_SCHEDULED_TIMER_HANDLESr%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrwr5rheapifyheappoprrZ_whenrmaxrMAXIMUM_SELECT_TIMEOUTrZ	_selectorZselectloggingINFODEBUGrlogrrrangepopleftrZ_runrr\r)rRZsched_countZ
new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrs











zBaseEventLoop._run_oncecCsHt|t|jkrdS|r2t|_ttjnt|j||_dS)N)r3rr#get_coroutine_origin_tracking_depthr#set_coroutine_origin_tracking_depthrZDEBUG_STACK_DEPTH)rRenabledrrrrs

z,BaseEventLoop._set_coroutine_origin_trackingcCs|jS)N)r)rRrrrrszBaseEventLoop.get_debugcCs ||_|r||j|dS)N)rrrr)rRrrrrrszBaseEventLoop.set_debug)N)N)NNN)NN)NN)N)r)rN)NN)FN)rN)NN)NN)PrerfrgrTrzrPrrrrrrrrrrrrrrrrrrrBrrrrrrrrrrrrrrr	rr
rr
rrr2r-r6r4r5r8rIrLr!r-r%rMr2Z
AI_PASSIVEr^r_rarbrdrrrhrjrkrlrvrrxryrzrrrrrrrrres



		&	
	


.,
	l23cr)rr)2__doc__rZcollections.abcZconcurrent.futuresrrrXrrRr!rrrrqrrrr!ImportErrorr*rrrrrrr	r
rr__all__r{r|r r4robjectrIrrr'r=rErGZProtocolrHZAbstractServerrhZAbstractEventLooprrrrr<module>sZ

		
;

Do