Hacked By AnonymousFox

Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/selectors.cpython-38.opt-1.pyc

U

e5d�H�@s�dZddlmZmZddlmZddlmZddlZddl	Z	ddl
Z
dZdZdd	�Z
ed
ddd
dg�Zde_e
jdkr�dej_dej_dej_dej_Gdd�de�ZGdd�ded�ZGdd�de�ZGdd�de�ZGdd�de�Zee	d ��rGd!d"�d"e�Zee	d#��r Gd$d%�d%e�Zee	d&��r<Gd'd(�d(e�Zee	d)��rXGd*d+�d+e�Zd+e�k�rjeZn:d%e�k�r|eZn(d(e�k�r�eZnd"e�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<zt|���}Wn*tttfk
rJtd�|��d�YnX|dkrbtd�|���|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.8/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�Sr)�lenr�
_fd_to_key�rrrr�__len__Bsz_SelectorMapping.__len__cCsDz|j�|�}|jj|WStk
r>td�|��d�YnXdS�N�{!r} is not registered)r�_fileobj_lookupr�KeyErrorr)rrrrrr�__getitem__Es
z_SelectorMapping.__getitem__cCst|jj�Sr)�iterrrr rrr�__iter__Lsz_SelectorMapping.__iter__N)�__name__�
__module__�__qualname__�__doc__rr!r&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)
        Nr.)rrrrr�
unregistervszBaseSelector.unregistercCs|�|�|�|||�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
        )r2r1r0rrr�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
        Nr.)r�timeoutrrr�select�szBaseSelector.selectcCsdS)zmClose the selector.

        This must be called to make sure that any underlying resource is freed.
        Nrr rrr�close�szBaseSelector.closecCsL|��}|dkrtd��z
||WStk
rFtd�|��d�YnXdS)zzReturn the key associated to a registered file object.

        Returns:
        SelectorKey for this file object
        NzSelector is closedr#)�get_map�RuntimeErrorr%r)rr�mappingrrr�get_key�s
zBaseSelector.get_keycCst�dS)z2Return a mapping of file objects to selector keys.Nr.r rrrr7�szBaseSelector.get_mapcCs|Srrr rrr�	__enter__�szBaseSelector.__enter__cGs|��dSr)r6)r�argsrrr�__exit__�szBaseSelector.__exit__)N)N)N)r)r*r+r,rr1r2r3r5r6r:r7r;r=rrrrr-Ps


r-)�	metaclassc@sTeZdZdZdd�Zdd�Zddd�Zd	d
�Zddd�Zd
d�Z	dd�Z
dd�ZdS)�_BaseSelectorImplzBase selector implementation.cCsi|_t|�|_dSr)rr�_mapr rrrr�sz_BaseSelectorImpl.__init__cCsNz
t|�WStk
rH|j��D]}|j|kr$|jYSq$�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_lookupNcCsb|r|ttB@r td�|���t||�|�||�}|j|jkrRtd�||j���||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered)	�
EVENT_READ�EVENT_WRITEr
rrr$rrr%�rrrrrCrrrr1�s�z_BaseSelectorImpl.registercCs@z|j�|�|��}Wn$tk
r:td�|��d�YnX|Sr")r�popr$r%rrBrrrr2�s
z_BaseSelectorImpl.unregistercCs�z|j|�|�}Wn$tk
r8td�|��d�YnX||jkr^|�|�|�|||�}n"||jkr�|j|d�}||j|j	<|S)Nr#)r)
rr$r%rrr2r1r�_replacerrFrrrr3�s


z_BaseSelectorImpl.modifycCs|j��d|_dSr)r�clearr@r rrrr6s
z_BaseSelectorImpl.closecCs|jSr)r@r rrrr7sz_BaseSelectorImpl.get_mapcCs(z|j|WStk
r"YdSXdS)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,rr$r1r2r3r6r7rJrrrrr?�s


r?cs`eZdZdZ�fdd�Zd�fdd�	Z�fdd�Zejd	krHdd
d�Z	ne
j
Z	ddd
�Z
�ZS)�SelectSelectorzSelect-based selector.cst���t�|_t�|_dSr)�superr�set�_readers�_writersr ��	__class__rrr%s
zSelectSelector.__init__Ncs@t��|||�}|t@r&|j�|j�|t@r<|j�|j�|Sr)rLr1rDrN�addrrErOrFrPrrr1*szSelectSelector.registercs,t��|�}|j�|j�|j�|j�|Sr)rLr2rN�discardrrOrBrPrrr22szSelectSelector.unregisterZwin32cCs$t�||||�\}}}|||gfSr)r5)r�r�w�_r4�xrrr�_select9szSelectSelector._selectc	Cs�|dkrdnt|d�}g}z|�|j|jg|�\}}}Wntk
rP|YSXt|�}t|�}||BD]J}d}||kr�|tO}||kr�|tO}|�|�}|rj|�	|||j
@f�qj|S�Nr)�maxrXrNrO�InterruptedErrorrMrDrErJ�appendr)	rr4�readyrTrUrVrrrCrrrr5?s$

zSelectSelector.select)N)N)N)r)r*r+r,rr1r2�sys�platformrXr5�
__classcell__rrrPrrK"s
rKcs^eZdZdZdZdZdZ�fdd�Zd
�fdd�	Z�fdd�Z	d�fd	d
�	Z
ddd�Z�ZS)�_PollLikeSelectorz<Base class shared between poll, epoll and devpoll selectors.Ncst���|��|_dSr)rLr�
_selector_clsrr rPrrr[s
z_PollLikeSelector.__init__cslt��|||�}d}|t@r&||jO}|t@r8||jO}z|j�|j|�Wnt��|��YnX|SrY)	rLr1rD�_EVENT_READrE�_EVENT_WRITErrr2)rrrrrCZ
poller_eventsrPrrr1_s

z_PollLikeSelector.registercs8t��|�}z|j�|j�Wntk
r2YnX|Sr)rLr2rr�OSErrorrBrPrrr2msz_PollLikeSelector.unregistercs�z|j|�|�}Wn$tk
r8t|�d��d�YnXd}||jkr�d}|t@r^||jO}|t@rp||jO}z|j�	|j
|�Wnt��|��YnXd}||j
kr�d}|r�|j||d�}||j|j
<|S)Nz is not registeredFrT)rr)rr$r%rrDrcrErdrr3rrLr2rrH)rrrrrCZchangedZselector_eventsrPrrr3ws.



z_PollLikeSelector.modifycCs�|dkrd}n|dkrd}nt�|d�}g}z|j�|�}Wntk
rV|YSX|D]V\}}d}||j@r||tO}||j@r�|tO}|�	|�}|r\|�
|||j@f�q\|S)Nr�@�@)�math�ceilr�pollr[rcrErdrDrJr\r)rr4r]�
fd_event_listr�eventrrCrrrr5�s(

z_PollLikeSelector.select)N)N)N)
r)r*r+r,rbrcrdrr1r2r3r5r`rrrPrraUs
raric@s"eZdZdZejZejZej	Z
dS)�PollSelectorzPoll-based selector.N)r)r*r+r,r5rirb�POLLINrc�POLLOUTrdrrrrrl�srl�epollcsDeZdZdZejZejZej	Z
dd�Zd	dd�Z�fdd�Z�Z
S)
�
EpollSelectorzEpoll-based selector.cCs
|j��Sr�rr
r rrrr
�szEpollSelector.filenoNc	Cs�|dkrd}n |dkrd}nt�|d�d}tt|j�d�}g}z|j�||�}Wntk
rl|YSX|D]V\}}d}|tj	@r�|t
O}|tj@r�|tO}|�
|�}|rr|�|||j@f�qr|S)N���rrfg����MbP?r)rgrhrZrrrrir[r5�EPOLLINrE�EPOLLOUTrDrJr\r)	rr4�max_evr]rjrrkrrCrrrr5�s*

zEpollSelector.selectcs|j��t���dSr�rr6rLr rPrrr6�s
zEpollSelector.close)N)r)r*r+r,r5rorbrsrcrtrdr
r6r`rrrPrrp�s
 rp�devpollcs:eZdZdZejZejZej	Z
dd�Z�fdd�Z�Z
S)�DevpollSelectorzSolaris /dev/poll selector.cCs
|j��Srrqr rrrr
�szDevpollSelector.filenocs|j��t���dSrrvr rPrrr6�s
zDevpollSelector.close)r)r*r+r,r5rwrbrmrcrnrdr
r6r`rrrPrrx�srx�kqueuecsXeZdZdZ�fdd�Zdd�Zd�fdd�	Z�fd	d
�Zddd�Z�fd
d�Z	�Z
S)�KqueueSelectorzKqueue-based selector.cst���t��|_dSr)rLrr5ryrr rPrrr�s
zKqueueSelector.__init__cCs
|j��Srrqr rrrr
szKqueueSelector.filenoNcs�t��|||�}z`|t@r@t�|jtjtj�}|j�	|gdd�|t
@rnt�|jtjtj�}|j�	|gdd�Wnt��|��YnX|SrY)
rLr1rDr5�keventr�KQ_FILTER_READZ	KQ_EV_ADDr�controlrE�KQ_FILTER_WRITEr2)rrrrrC�kevrPrrr1s ��zKqueueSelector.registercs�t��|�}|jt@rVt�|jtjtj�}z|j	�
|gdd�Wntk
rTYnX|jt@r�t�|jtj
tj�}z|j	�
|gdd�Wntk
r�YnX|SrY)rLr2rrDr5r{rr|ZKQ_EV_DELETErr}rerEr~)rrrCrrPrrr2s$
�
�zKqueueSelector.unregisterc
Cs�|dkrdnt|d�}t|j�}g}z|j�d||�}Wntk
rP|YSX|D]Z}|j}|j}d}|tj	kr||t
O}|tjkr�|tO}|�
|�}	|	rV|�|	||	j@f�qV|SrY)rZrrrr}r[Zident�filterr5r|rDr~rErJr\r)
rr4rur]Zkev_listrr�flagrrCrrrr5)s&




zKqueueSelector.selectcs|j��t���dSrrvr rPrrr6?s
zKqueueSelector.close)N)N)r)r*r+r,rr
r1r2r5r6r`rrrPrrz�s
rz) r,�abcrr�collectionsrZcollections.abcrrgr5r^rDrErr�version_inforrrrrr-r?rKra�hasattrrlrprxrz�globalsZDefaultSelectorrrrr�<module>sL
~T3Z.M

Hacked By AnonymousFox1.0, Coded By AnonymousFox