Your IP : 18.223.209.189


Current Path : /lib64/python3.6/asyncio/__pycache__/
Upload File :
Current File : //lib64/python3.6/asyncio/__pycache__/events.cpython-36.pyc

3


 \�[�@s�dZddddddddd	d
ddd
dgZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
dd�Zdd�Zd3dd�Zdd�Zd4dd�ZGdd�d�ZGd d�de�ZGd!d�d�ZGd"d�d�ZGd#d�d�ZGd$d%�d%e�Zdae	j�ZGd&d'�d'e	j�Ze�Zd(d�Zd)d
�Z d*d+�Z!d,d�Z"d-d�Z#d.d�Z$d/d	�Z%d0d
�Z&d1d�Z'd2d�Z(dS)5z!Event loop and event loop policy.�AbstractEventLoopPolicy�AbstractEventLoop�AbstractServer�Handle�TimerHandle�get_event_loop_policy�set_event_loop_policy�get_event_loop�set_event_loop�new_event_loop�get_child_watcher�set_child_watcher�_set_running_loop�_get_running_loop�N�)�compat)�	constantscCsttjrtj|�}nt|d�r"|j}tj|�r>|j}|j|j	fSt
|tj�rTt
|j�Stjrpt
|tj�rpt
|j�SdS)N�__wrapped__)rZPY34�inspectZunwrap�hasattrrZ
isfunction�__code__�co_filename�co_firstlineno�
isinstance�	functools�partial�_get_function_source�func�
partialmethod)r�code�r �/usr/lib64/python3.6/events.pyrs



rcCsJg}|r|jdd�|D��|r8|jdd�|j�D��ddj|�dS)z�Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    css|]}tj|�VqdS)N)�reprlib�repr)�.0�argr r r!�	<genexpr>1sz*_format_args_and_kwargs.<locals>.<genexpr>css$|]\}}dj|tj|��VqdS)z{}={}N)�formatr"r#)r$�k�vr r r!r&3s�(z, �))�extend�items�join)�args�kwargsr-r r r!�_format_args_and_kwargs)s
r1�cCs�t|tj�r.t||�|}t|j|j|j|�St|d�rF|j	rF|j	}n t|d�r^|j
r^|j
}nt|�}|t||�7}|r�||7}|S)N�__qualname__�__name__)rrrr1�_format_callbackrr/�keywordsrr3r4r#)rr/r0�suffix�	func_reprr r r!r58sr5cCs(t||d�}t|�}|r$|d|7}|S)Nz	 at %s:%s)r5r)rr/r8�sourcer r r!�_format_callback_sourceIs
r:cCsD|dkrtj�j}|dkr tj}tjjtj|�|dd�}|j	�|S)zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)�limit�lookup_lines)
�sys�	_getframe�f_backrZDEBUG_STACK_DEPTH�	traceback�StackSummary�extract�
walk_stack�reverse)�fr;�stackr r r!�
extract_stackQs
rGc@s<eZdZdZdZd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dS)rz1Object returned by callback registration methods.�	_callback�_args�
_cancelled�_loop�_source_traceback�_repr�__weakref__cCsD||_||_||_d|_d|_|jj�r:ttjd��|_	nd|_	dS)NFr)
rKrHrIrJrM�	get_debugrGr=r>rL)�self�callbackr/�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__r4rJ�appendrHr:rIrL)rP�info�framer 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|_|jj�r t|�|_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!�cancel�s

z
Handle.cancelcCs|y|j|j�Wnbtk
rr}zFt|j|j�}dj|�}|||d�}|jrV|j|d<|jj|�WYdd}~XnXd}dS)NzException in callback {})�messageZ	exception�handleZsource_traceback)rHrI�	Exceptionr:r'rLrK�call_exception_handler)rP�exc�cb�msg�contextr r r!�_run�s

zHandle._runN)rHrIrJrKrLrMrN)
r4�
__module__r3�__doc__�	__slots__rSrYr[r\rer r r r!rbscsxeZdZdZddgZ�fdd�Z�fdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Z�ZS)rz7Object returned by timed callback registration methods.�
_scheduled�_whencs:|dk	st�t�j|||�|jr*|jd=||_d|_dS)NrFrT)�AssertionError�superrSrLrjri)rP�whenrQr/rR)rUr r!rS�szTimerHandle.__init__cs.t�j�}|jrdnd}|j|d|j�|S)N�rzwhen=%s)rlrYrJ�insertrj)rPrW�pos)rUr r!rY�s
zTimerHandle._repr_infocCs
t|j�S)N)�hashrj)rPr r r!�__hash__�szTimerHandle.__hash__cCs|j|jkS)N)rj)rP�otherr r r!�__lt__�szTimerHandle.__lt__cCs|j|jkrdS|j|�S)NT)rj�__eq__)rPrsr r r!�__le__�szTimerHandle.__le__cCs|j|jkS)N)rj)rPrsr r r!�__gt__�szTimerHandle.__gt__cCs|j|jkrdS|j|�S)NT)rjru)rPrsr r r!�__ge__�szTimerHandle.__ge__cCs>t|t�r:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJ�NotImplemented)rPrsr r r!ru�s
zTimerHandle.__eq__cCs|j|�}|tkrtS|S)N)rury)rPrsZequalr r r!�__ne__�s
zTimerHandle.__ne__cs |js|jj|�t�j�dS)N)rJrK�_timer_handle_cancelledrlr\)rP)rUr r!r\�szTimerHandle.cancel)r4rfr3rgrhrSrYrrrtrvrwrxrurzr\�
__classcell__r r )rUr!r�sc@s eZdZdZdd�Zdd�ZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving.  This leaves existing connections open.)ry)rPr r r!�close�szAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)ry)rPr r r!�wait_closed�szAbstractServer.wait_closedN)r4rfr3rgr}r~r r r r!r�sc	@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d$d$d$d%�d&d'�Zdhd(d)�Zdid*d$d$d$d*d*d*d+�d,d-�Zdjejejd*d.d*d*d*d/�d0d1�Zd*d*d*d2�d3d4�Zd*d.d*d5�d6d7�Zdkd$d$d$d*d*d*d*d8�d9d:�Zd;d<�Zd=d>�Z e!j"e!j"e!j"d?�d@dA�Z#e!j"e!j"e!j"d?�dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4ddde�Z5dfdg�Z6d*S)lrzAbstract event loop.cCst�dS)z*Run the event loop until stop() is called.N)�NotImplementedError)rPr r r!�run_forever�szAbstractEventLoop.run_forevercCst�dS)zpRun the event loop until a Future is done.

        Return the Future's result, or raise its exception.
        N)r)rPZfuturer r r!�run_until_complete�sz$AbstractEventLoop.run_until_completecCst�dS)z�Stop 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.
        N)r)rPr r r!�stop�szAbstractEventLoop.stopcCst�dS)z3Return whether the event loop is currently running.N)r)rPr r r!�
is_running�szAbstractEventLoop.is_runningcCst�dS)z*Returns True if the event loop was closed.N)r)rPr r r!�	is_closedszAbstractEventLoop.is_closedcCst�dS)z�Close the loop.

        The loop should not be running.

        This is idempotent and irreversible.

        No other methods should be called after this one.
        N)r)rPr r r!r}s	zAbstractEventLoop.closecCst�dS)z,Shutdown all active asynchronous generators.N)r)rPr r r!�shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCst�dS)z3Notification that a TimerHandle has been cancelled.N)r)rPr^r r r!r{sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|��S)Nr)�
call_later)rPrQr/r r r!�	call_soonszAbstractEventLoop.call_sooncGst�dS)N)r)rPZdelayrQr/r r r!r�szAbstractEventLoop.call_latercGst�dS)N)r)rPrmrQr/r r r!�call_atszAbstractEventLoop.call_atcCst�dS)N)r)rPr r r!�time"szAbstractEventLoop.timecCst�dS)N)r)rPr r r!�
create_future%szAbstractEventLoop.create_futurecCst�dS)N)r)rP�coror r r!�create_task*szAbstractEventLoop.create_taskcGst�dS)N)r)rPrQr/r r r!�call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGst�dS)N)r)rP�executorrr/r r r!�run_in_executor2sz!AbstractEventLoop.run_in_executorcCst�dS)N)r)rPr�r r r!�set_default_executor5sz&AbstractEventLoop.set_default_executorr)�family�type�proto�flagscCst�dS)N)r)rP�host�portr�r�r�r�r r r!�getaddrinfo:szAbstractEventLoop.getaddrinfocCst�dS)N)r)rPZsockaddrr�r r r!�getnameinfo=szAbstractEventLoop.getnameinfoN)�sslr�r�r��sock�
local_addr�server_hostnamecCst�dS)N)r)rP�protocol_factoryr�r�r�r�r�r�r�r�r�r r r!�create_connection@sz#AbstractEventLoop.create_connection�d)r�r�r��backlogr��
reuse_address�
reuse_portcCst�dS)a�A 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.
        N)r)rPr�r�r�r�r�r�r�r�r�r�r r r!�
create_serverEs'zAbstractEventLoop.create_server)r�r�r�cCst�dS)N)r)rPr��pathr�r�r�r r r!�create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)r�r�r�cCst�dS)a#A 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 systsem 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.
        N)r)rPr�r�r�r�r�r r r!�create_unix_serverssz$AbstractEventLoop.create_unix_server)r�r�r�r�r��allow_broadcastr�cCst�dS)a�A 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 or socket.AF_INET6 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.
        N)r)rPr�r�Zremote_addrr�r�r�r�r�r�r�r r r!�create_datagram_endpoint�s!z*AbstractEventLoop.create_datagram_endpointcCst�dS)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.N)r)rPr��piper r r!�connect_read_pipe�sz#AbstractEventLoop.connect_read_pipecCst�dS)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.N)r)rPr�r�r r r!�connect_write_pipe�sz$AbstractEventLoop.connect_write_pipe)�stdin�stdout�stderrcKst�dS)N)r)rPr��cmdr�r�r�r0r r r!�subprocess_shell�sz"AbstractEventLoop.subprocess_shellcOst�dS)N)r)rPr�r�r�r�r/r0r r r!�subprocess_exec�sz!AbstractEventLoop.subprocess_execcGst�dS)N)r)rP�fdrQr/r r r!�
add_reader�szAbstractEventLoop.add_readercCst�dS)N)r)rPr�r r r!�
remove_reader�szAbstractEventLoop.remove_readercGst�dS)N)r)rPr�rQr/r r r!�
add_writer�szAbstractEventLoop.add_writercCst�dS)N)r)rPr�r r r!�
remove_writer�szAbstractEventLoop.remove_writercCst�dS)N)r)rPr��nbytesr r r!�	sock_recv�szAbstractEventLoop.sock_recvcCst�dS)N)r)rPr��datar r r!�sock_sendall�szAbstractEventLoop.sock_sendallcCst�dS)N)r)rPr�Zaddressr r r!�sock_connect�szAbstractEventLoop.sock_connectcCst�dS)N)r)rPr�r r r!�sock_accept�szAbstractEventLoop.sock_acceptcGst�dS)N)r)rP�sigrQr/r r r!�add_signal_handler�sz$AbstractEventLoop.add_signal_handlercCst�dS)N)r)rPr�r r r!�remove_signal_handler�sz'AbstractEventLoop.remove_signal_handlercCst�dS)N)r)rP�factoryr r r!�set_task_factory�sz"AbstractEventLoop.set_task_factorycCst�dS)N)r)rPr r r!�get_task_factory�sz"AbstractEventLoop.get_task_factorycCst�dS)N)r)rPr r r!�get_exception_handlersz'AbstractEventLoop.get_exception_handlercCst�dS)N)r)rPZhandlerr r r!�set_exception_handlersz'AbstractEventLoop.set_exception_handlercCst�dS)N)r)rPrdr r r!�default_exception_handlersz+AbstractEventLoop.default_exception_handlercCst�dS)N)r)rPrdr r r!r`sz(AbstractEventLoop.call_exception_handlercCst�dS)N)r)rPr r r!rOszAbstractEventLoop.get_debugcCst�dS)N)r)rPZenabledr r r!�	set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgr�r�r�r�r�r}r�r{r�r�r�r�r�r�r�r�r�r�r�r��socketZ	AF_UNSPECZ
AI_PASSIVEr�r�r�r�r�r��
subprocess�PIPEr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r`rOr�r r r r!r�st

'!

	c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz-Abstract policy for accessing the event loop.cCst�dS)a:Get the event loop for the current context.

        Returns an event loop object implementing the BaseEventLoop interface,
        or raises an exception in case no event loop has been set for the
        current context and the current policy does not specify to create one.

        It should never return None.N)r)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCst�dS)z3Set the event loop for the current context to loop.N)r)rPrRr r r!r	$sz&AbstractEventLoopPolicy.set_event_loopcCst�dS)z�Create and return a new event loop object according to this
        policy's rules. If there's need to set this loop as the event loop for
        the current context, set_event_loop must be called explicitly.N)r)rPr r r!r
(sz&AbstractEventLoopPolicy.new_event_loopcCst�dS)z$Get the watcher for child processes.N)r)rPr r r!r0sz)AbstractEventLoopPolicy.get_child_watchercCst�dS)z$Set the watcher for child processes.N)r)rP�watcherr r r!r4sz)AbstractEventLoopPolicy.set_child_watcherN)	r4rfr3rgrr	r
rrr r r r!rs
c@sFeZdZdZdZGdd�dej�Zdd�Zdd�Z	d	d
�Z
dd�ZdS)
�BaseDefaultEventLoopPolicya�Default policy implementation for accessing the event loop.

    In this policy, each thread has its own event loop.  However, we
    only automatically create an event loop by default for the main
    thread; other threads by default have no event loop.

    Other policies may have different rules (e.g. a single global
    event loop, or automatically creating an event loop per thread, or
    using some other notion of context to which an event loop is
    associated).
    Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK�_set_calledr r r r!�_LocalHsr�cCs|j�|_dS)N)r��_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jjr4ttj�tj�r4|j|j��|jjdkrRt	dtj�j
��|jjS)zSGet the event loop.

        This may be None or an instance of EventLoop.
        Nz,There is no current event loop in thread %r.)r�rKr�r�	threadingZcurrent_threadZ_MainThreadr	r
�RuntimeError�name)rPr r r!rOs
z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|t�st�||j_dS)zSet the event loop.TN)r�r�rrrkrK)rPrRr r r!r	]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|j�S)zvCreate a new event loop.

        You must call set_event_loop() to make this the current event
        loop.
        )�
_loop_factory)rPr r r!r
csz)BaseDefaultEventLoopPolicy.new_event_loop)r4rfr3rgr�r��localr�rSrr	r
r r r r!r�9sr�c@seZdZdZdS)�_RunningLoopN)NN)r4rfr3�loop_pidr r r r!r�wsr�cCs&tj\}}|dk	r"|tj�kr"|SdS)z�Return the running event loop or None.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)�
_running_loopr��os�getpid)Zrunning_loop�pidr r r!r~s
cCs|tj�ft_dS)z�Set the running event loop.

    This is a low-level function intended to be used by event loops.
    This function is thread-specific.
    N)r�r�r�r�)rRr r r!r
�sc	Cs.t� tdkr ddlm}|�aWdQRXdS)Nr)�DefaultEventLoopPolicy)�_lock�_event_loop_policyr2r�)r�r r r!�_init_event_loop_policy�sr�cCstdkrt�tS)z"Get the current event loop policy.N)r�r�r r r r!r�scCs|dkst|t�st�|adS)zZSet the current event loop policy.

    If policy is None, the default policy is restored.N)rrrkr�)Zpolicyr r r!r�scCst�}|dk	r|St�j�S)aGReturn an asyncio event loop.

    When called from a coroutine or a callback (e.g. scheduled with call_soon
    or similar API), this function will always return the running event loop.

    If there is no running event loop set, the function will return
    the result of `get_event_loop_policy().get_event_loop()` call.
    N)rrr)Zcurrent_loopr r r!r�s	cCst�j|�dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr	)rRr r r!r	�scCs
t�j�S)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr
r r r r!r
�scCs
t�j�S)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rrr r r r!r�scCst�j|�S)zMEquivalent to calling
    get_event_loop_policy().set_child_watcher(watcher).)rr)r�r r r!r�s)r2)NN))rg�__all__rrr�r"r�r�r=r�r@r2rrrr1r5r:rGrrrrrr�r�ZLockr�r�r�r�rr
r�rrrr	r
rrr r r r!�<module>sZ

>85"7