ok

Mini Shell

Direktori : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/selectors.cpython-36.opt-1.pyc

3


 \�K�@s�dZddlmZmZddlmZmZddlZddlZddl	Z	d)Z
d*Zdd�Zedd	d
ddg�Z
d
e
_e	jd+kr�de
j_de
j_de
j_de
j_Gdd�de�ZGdd�ded�ZGdd�de�ZGdd�de�Zeed�r�Gdd�de�Zeed ��rGd!d"�d"e�Zeed#��r"Gd$d%�d%e�Zeed&��r>Gd'd(�d(e�Zd(e�k�rPeZn:d"e�k�rbeZn(d%e�k�rteZnde�k�r�eZneZdS),z|Selectors module.

This module allows high-level and efficient I/O multiplexing, built upon the
`select` module primitives.
�)�ABCMeta�abstractmethod)�
namedtuple�MappingN�c
Csft|t�r|}n<yt|j��}Wn*tttfk
rJtdj|��d�YnX|dkrbtdj|���|S)z�Return a file descriptor from a file object.

    Parameters:
    fileobj -- file object or file descriptor

    Returns:
    corresponding file descriptor

    Raises:
    ValueError if the object is invalid
    zInvalid file object: {!r}NrzInvalid file descriptor: {})�
isinstance�int�fileno�AttributeError�	TypeError�
ValueError�format)�fileobj�fd�r�!/usr/lib64/python3.6/selectors.py�_fileobj_to_fds
r�SelectorKeyrr�events�dataz�SelectorKey(fileobj, fd, events, data)

    Object used to associate a file object to its backing
    file descriptor, selected event mask, and attached data.
��zFile object registered.zUnderlying file descriptor.z3Events that must be waited for on this file object.zzOptional opaque data associated to this file object.
    For example, this could be used to store a per-client session ID.c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�_SelectorMappingz)Mapping of file objects to selector keys.cCs
||_dS)N)�	_selector)�selfZselectorrrr�__init__>sz_SelectorMapping.__init__cCst|jj�S)N)�lenr�
_fd_to_key)rrrr�__len__Asz_SelectorMapping.__len__cCsBy|jj|�}|jj|Stk
r<tdj|��d�YnXdS)Nz{!r} is not registered)r�_fileobj_lookupr�KeyErrorr
)rrrrrr�__getitem__Ds
z_SelectorMapping.__getitem__cCst|jj�S)N)�iterrr)rrrr�__iter__Ksz_SelectorMapping.__iter__N)�__name__�
__module__�__qualname__�__doc__rrr!r#rrrrr;s
rc@sneZdZdZeddd��Zedd��Zddd�Zedd	d
��Zdd�Z	d
d�Z
edd��Zdd�Zdd�Z
dS)�BaseSelectora-Selector abstract base class.

    A selector supports registering file objects to be monitored for specific
    I/O events.

    A file object is a file descriptor or any object with a `fileno()` method.
    An arbitrary object can be attached to the file object, which can be used
    for example to store context information, a callback, etc.

    A selector can use various implementations (select(), poll(), epoll()...)
    depending on the platform. The default `Selector` class uses the most
    efficient implementation on the current platform.
    NcCst�dS)a3Register a file object.

        Parameters:
        fileobj -- file object or file descriptor
        events  -- events to monitor (bitwise mask of EVENT_READ|EVENT_WRITE)
        data    -- attached data

        Returns:
        SelectorKey instance

        Raises:
        ValueError if events is invalid
        KeyError if fileobj is already registered
        OSError if fileobj is closed or otherwise is unacceptable to
                the underlying system call (if a system call is made)

        Note:
        OSError may or may not be raised
        N)�NotImplementedError)rrrrrrr�register^szBaseSelector.registercCst�dS)ajUnregister a file object.

        Parameters:
        fileobj -- file object or file descriptor

        Returns:
        SelectorKey instance

        Raises:
        KeyError if fileobj is not registered

        Note:
        If fileobj is registered but has since been closed this does
        *not* raise OSError (even if the wrapped syscall does)
        N)r))rrrrr�
unregisteruszBaseSelector.unregistercCs|j|�|j|||�S)ayChange a registered file object monitored events or attached data.

        Parameters:
        fileobj -- file object or file descriptor
        events  -- events to monitor (bitwise mask of EVENT_READ|EVENT_WRITE)
        data    -- attached data

        Returns:
        SelectorKey instance

        Raises:
        Anything that unregister() or register() raises
        )r+r*)rrrrrrr�modify�s
zBaseSelector.modifycCst�dS)aqPerform the actual selection, until some monitored file objects are
        ready or a timeout expires.

        Parameters:
        timeout -- if timeout > 0, this specifies the maximum wait time, in
                   seconds
                   if timeout <= 0, the select() call won't block, and will
                   report the currently ready file objects
                   if timeout is None, select() will block until a monitored
                   file object becomes ready

        Returns:
        list of (key, events) for ready file objects
        `events` is a bitwise mask of EVENT_READ|EVENT_WRITE
        N)r))r�timeoutrrr�select�szBaseSelector.selectcCsdS)zmClose the selector.

        This must be called to make sure that any underlying resource is freed.
        Nr)rrrr�close�szBaseSelector.closecCsJ|j�}|dkrtd��y||Stk
rDtdj|��d�YnXdS)zzReturn the key associated to a registered file object.

        Returns:
        SelectorKey for this file object
        NzSelector is closedz{!r} is not registered)�get_map�RuntimeErrorr r
)rr�mappingrrr�get_key�szBaseSelector.get_keycCst�dS)z2Return a mapping of file objects to selector keys.N)r))rrrrr0�szBaseSelector.get_mapcCs|S)Nr)rrrr�	__enter__�szBaseSelector.__enter__cGs|j�dS)N)r/)r�argsrrr�__exit__�szBaseSelector.__exit__)N)N)N)r$r%r&r'rr*r+r,r.r/r3r0r4r6rrrrr(Os

r()�	metaclassc@sTeZdZdZdd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Z	dd�Z
dd�ZdS)�_BaseSelectorImplzBase selector implementation.cCsi|_t|�|_dS)N)rr�_map)rrrrr�sz_BaseSelectorImpl.__init__cCsHyt|�Stk
rBx"|jj�D]}|j|kr$|jSq$W�YnXdS)alReturn a file descriptor from a file object.

        This wraps _fileobj_to_fd() to do an exhaustive search in case
        the object is invalid but we still have it in our map.  This
        is used by unregister() so we can unregister an object that
        was previously registered even if it is closed.  It is also
        used by _SelectorMapping.
        N)rrr�valuesrr)rr�keyrrrr�s	

z!_BaseSelectorImpl._fileobj_lookupNcCsd|s|ttB@r"tdj|���t||j|�||�}|j|jkrTtdj||j���||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered)	�
EVENT_READ�EVENT_WRITErr
rrrrr )rrrrr;rrrr*�sz_BaseSelectorImpl.registercCs@y|jj|j|��}Wn$tk
r:tdj|��d�YnX|S)Nz{!r} is not registered)r�poprr r
)rrr;rrrr+�s
z_BaseSelectorImpl.unregistercCs�y|j|j|�}Wn$tk
r8tdj|��d�YnX||jkr^|j|�|j|||�}n"||jkr�|j|d�}||j|j	<|S)Nz{!r} is not registered)r)
rrr r
rr+r*r�_replacer)rrrrr;rrrr,�s


z_BaseSelectorImpl.modifycCs|jj�d|_dS)N)r�clearr9)rrrrr/s
z_BaseSelectorImpl.closecCs|jS)N)r9)rrrrr0sz_BaseSelectorImpl.get_mapcCs$y
|j|Stk
rdSXdS)z�Return the key associated to a given file descriptor.

        Parameters:
        fd -- file descriptor

        Returns:
        corresponding key, or None if not found
        N)rr )rrrrr�_key_from_fds	
z_BaseSelectorImpl._key_from_fd)N)N)r$r%r&r'rrr*r+r,r/r0rArrrrr8�s


r8cs`eZdZdZ�fdd�Zd�fdd�	Z�fdd�Zejd	krHdd
d�Z	ne
j
Z	ddd
�Z
�ZS)�SelectSelectorzSelect-based selector.cst�j�t�|_t�|_dS)N)�superr�set�_readers�_writers)r)�	__class__rrr%s
zSelectSelector.__init__Ncs@t�j|||�}|t@r&|jj|j�|t@r<|jj|j�|S)N)rCr*r<rE�addrr=rF)rrrrr;)rGrrr**szSelectSelector.registercs,t�j|�}|jj|j�|jj|j�|S)N)rCr+rE�discardrrF)rrr;)rGrrr+2szSelectSelector.unregisterZwin32cCs$tj||||�\}}}|||gfS)N)r.)r�r�w�_r-�xrrr�_select9szSelectSelector._selectc	
Cs�|dkrdnt|d�}g}y|j|j|jg|�\}}}Wntk
rL|SXt|�}t|�}xV||BD]J}d}||kr�|tO}||kr�|tO}|j|�}|rh|j	|||j
@f�qhW|S)Nr)�maxrNrErF�InterruptedErrorrDr<r=rA�appendr)	rr-�readyrJrKrLrrr;rrrr.?s$
zSelectSelector.select)N)N)N)r$r%r&r'rr*r+�sys�platformrNr.�
__classcell__rr)rGrrB"s
rB�pollcsDeZdZdZ�fdd�Zd�fdd�	Z�fdd�Zdd	d
�Z�ZS)
�PollSelectorzPoll-based selector.cst�j�tj�|_dS)N)rCrr.rV�_poll)r)rGrrrZs
zPollSelector.__init__NcsLt�j|||�}d}|t@r&|tjO}|t@r8|tjO}|jj|j|�|S)Nr)	rCr*r<r.�POLLINr=�POLLOUTrXr)rrrrr;�poll_events)rGrrr*^s

zPollSelector.registercst�j|�}|jj|j�|S)N)rCr+rXr)rrr;)rGrrr+hszPollSelector.unregisterc
Cs�|dkrd}n|dkrd}ntj|d�}g}y|jj|�}Wntk
rR|SXx^|D]V\}}d}|tj@rz|tO}|tj@r�|t	O}|j
|�}|rZ|j|||j@f�qZW|S)Nrg@�@)
�math�ceilrXrVrPr.rYr=rZr<rArQr)rr-rR�
fd_event_listr�eventrr;rrrr.ms(
zPollSelector.select)N)N)	r$r%r&r'rr*r+r.rUrr)rGrrWWs

rW�epollcsXeZdZdZ�fdd�Zdd�Zd�fdd�	Z�fd	d
�Zddd�Z�fd
d�Z	�Z
S)�
EpollSelectorzEpoll-based selector.cst�j�tj�|_dS)N)rCrr.r`�_epoll)r)rGrrr�s
zEpollSelector.__init__cCs
|jj�S)N)rbr	)rrrrr	�szEpollSelector.filenoNcstt�j|||�}d}|t@r&|tjO}|t@r8|tjO}y|jj|j|�Wn"t	k
rnt�j
|��YnX|S)Nr)rCr*r<r.�EPOLLINr=�EPOLLOUTrbr�
BaseExceptionr+)rrrrr;Zepoll_events)rGrrr*�s

zEpollSelector.registercs8t�j|�}y|jj|j�Wntk
r2YnX|S)N)rCr+rbr�OSError)rrr;)rGrrr+�szEpollSelector.unregisterc	
Cs�|dkrd}n |dkrd}ntj|d�d}tt|j�d�}g}y|jj||�}Wntk
rh|SXx^|D]V\}}d}|tj	@r�|t
O}|tj@r�|tO}|j
|�}|rp|j|||j@f�qpW|S)Nrrg@�@g����MbP?���)r\r]rOrrrbrVrPr.rcr=rdr<rArQr)	rr-�max_evrRr^rr_rr;rrrr.�s*
zEpollSelector.selectcs|jj�t�j�dS)N)rbr/rC)r)rGrrr/�s
zEpollSelector.close)N)N)r$r%r&r'rr	r*r+r.r/rUrr)rGrra�s

 ra�devpollcsXeZdZdZ�fdd�Zdd�Zd�fdd�	Z�fd	d
�Zddd�Z�fd
d�Z	�Z
S)�DevpollSelectorzSolaris /dev/poll selector.cst�j�tj�|_dS)N)rCrr.ri�_devpoll)r)rGrrr�s
zDevpollSelector.__init__cCs
|jj�S)N)rkr	)rrrrr	�szDevpollSelector.filenoNcsLt�j|||�}d}|t@r&|tjO}|t@r8|tjO}|jj|j|�|S)Nr)	rCr*r<r.rYr=rZrkr)rrrrr;r[)rGrrr*�s

zDevpollSelector.registercst�j|�}|jj|j�|S)N)rCr+rkr)rrr;)rGrrr+�szDevpollSelector.unregisterc
Cs�|dkrd}n|dkrd}ntj|d�}g}y|jj|�}Wntk
rR|SXx^|D]V\}}d}|tj@rz|tO}|tj@r�|t	O}|j
|�}|rZ|j|||j@f�qZW|S)Nrg@�@)
r\r]rkrVrPr.rYr=rZr<rArQr)rr-rRr^rr_rr;rrrr.�s(
zDevpollSelector.selectcs|jj�t�j�dS)N)rkr/rC)r)rGrrr/s
zDevpollSelector.close)N)N)r$r%r&r'rr	r*r+r.r/rUrr)rGrrj�s

rj�kqueuecsXeZdZdZ�fdd�Zdd�Zd�fdd�	Z�fd	d
�Zddd�Z�fd
d�Z	�Z
S)�KqueueSelectorzKqueue-based selector.cst�j�tj�|_dS)N)rCrr.rl�_kqueue)r)rGrrrs
zKqueueSelector.__init__cCs
|jj�S)N)rnr	)rrrrr	szKqueueSelector.filenoNcs�t�j|||�}y`|t@r@tj|jtjtj�}|jj	|gdd�|t
@rntj|jtjtj�}|jj	|gdd�Wn"tk
r�t�j
|��YnX|S)Nr)rCr*r<r.�keventr�KQ_FILTER_READZ	KQ_EV_ADDrn�controlr=�KQ_FILTER_WRITErer+)rrrrr;�kev)rGrrr*szKqueueSelector.registercs�t�j|�}|jt@rVtj|jtjtj�}y|j	j
|gdd�Wntk
rTYnX|jt@r�tj|jtj
tj�}y|j	j
|gdd�Wntk
r�YnX|S)Nr)rCr+rr<r.rorrpZKQ_EV_DELETErnrqrfr=rr)rrr;rs)rGrrr+'s 

zKqueueSelector.unregisterc

Cs�|dkrdnt|d�}t|j�}g}y|jjd||�}Wntk
rL|SXxb|D]Z}|j}|j}d}|tj	krz|t
O}|tjkr�|tO}|j
|�}	|	rT|j|	||	j@f�qTW|S)Nr)rOrrrnrqrPZident�filterr.rpr<rrr=rArQr)
rr-rhrRZkev_listrsr�flagrr;rrrr.<s&




zKqueueSelector.selectcs|jj�t�j�dS)N)rnr/rC)r)rGrrr/Rs
zKqueueSelector.close)N)N)r$r%r&r'rr	r*r+r.r/rUrr)rGrrm
s
rmr�)rr)r'�abcrr�collectionsrrr\r.rSr<r=rr�version_inforrrrrr(r8rB�hasattrrWrarjrm�globalsZDefaultSelectorrrrr�<module>sH
~U3
1G8M

Zerion Mini Shell 1.0