Your IP : 3.129.42.59


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/selectors.cpython-310.opt-2.pyc

o

6��fPL�@s�	ddlmZmZddlmZddlmZddlZddlZddl	Z	dZ
dZdd�Zed	gd
��Z
de
_e	jdkrHd
e
j_de
j_de
j_de
j_Gdd�de�ZGdd�ded�ZGdd�de�ZGdd�de�ZGdd�de�Zeed�r~Gdd�de�Zeed�r�Gd d!�d!e�Zeed"�r�Gd#d$�d$e�Zeed%�r�Gd&d'�d'e�Zd(d)�Zed%�r�eZdSed�r�eZdSed"�r�eZdSed�r�eZdSeZdS)*�)�ABCMeta�abstractmethod)�
namedtuple)�MappingN��c
Csb	t|t�r	|}nzt|���}Wntttfy#td�|��d�w|dkr/td�|���|S)NzInvalid file object: {!r}rzInvalid file descriptor: {})�
isinstance�int�fileno�AttributeError�	TypeError�
ValueError�format)�fileobj�fd�r�0/opt/alt/python310/lib64/python3.10/selectors.py�_fileobj_to_fds
���r�SelectorKey)rr�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@s.eZdZ	dd�Zdd�Zdd�Zdd�Zd	S)
�_SelectorMappingcCs
||_dS�N)�	_selector)�self�selectorrrr�__init__@�
z_SelectorMapping.__init__cC�t|jj�Sr)�lenr�
_fd_to_key�rrrr�__len__C�z_SelectorMapping.__len__cCs:z
|j�|�}|jj|WStytd�|��d�w�N�{!r} is not registered)r�_fileobj_lookupr"�KeyErrorr)rrrrrr�__getitem__Fs�z_SelectorMapping.__getitem__cCr r)�iterrr"r#rrr�__iter__Mr%z_SelectorMapping.__iter__N)�__name__�
__module__�__qualname__rr$r*r,rrrrr=src@sleZdZ	eddd��Zedd��Zddd�Zeddd	��Zd
d�Zdd
�Z	edd��Z
dd�Zdd�ZdS)�BaseSelectorNcC�	t�r��NotImplementedError�rrrrrrr�register`szBaseSelector.registercCr1rr2)rrrrr�
unregisterw�zBaseSelector.unregistercCs	|�|�|�|||�Sr)r6r5r4rrr�modify�s

zBaseSelector.modifycCr1rr2)r�timeoutrrr�select�r7zBaseSelector.selectcCs	dSrrr#rrr�close�szBaseSelector.closecCsD	|��}|dur
td��z||WSty!td�|��d�w)NzSelector is closedr')�get_map�RuntimeErrorr)r)rr�mappingrrr�get_key�s
�zBaseSelector.get_keycCr1rr2r#rrrr<�szBaseSelector.get_mapcCs|Srrr#rrr�	__enter__�szBaseSelector.__enter__cGs|��dSr)r;)r�argsrrr�__exit__�r%zBaseSelector.__exit__r)
r-r.r/rr5r6r8r:r;r?r<r@rBrrrrr0Qs


r0)�	metaclassc@sReZdZ	dd�Zdd�Zddd�Zdd	�Zdd
d�Zdd
�Zdd�Z	dd�Z
dS)�_BaseSelectorImplcCsi|_t|�|_dSr)r"r�_mapr#rrrr�sz_BaseSelectorImpl.__init__cCsF	zt|�WSty"|j��D]}|j|ur |jYSq�wr)rr
r"�valuesrr�rr�keyrrrr(�s

��z!_BaseSelectorImpl._fileobj_lookupNcCsb|r	|ttB@rtd�|���t||�|�||�}|j|jvr)td�||j���||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered)	�
EVENT_READ�EVENT_WRITEr
rrr(rr"r)�rrrrrHrrrr5�s
�z_BaseSelectorImpl.registercCs8z|j�|�|��}W|Stytd�|��d�wr&)r"�popr(r)rrGrrrr6�s��z_BaseSelectorImpl.unregistercCs�z
|j|�|�}Wntytd�|��d�w||jkr-|�|�|�|||�}|S||jkr>|j|d�}||j|j	<|S)Nr')r)
r"r(r)rrr6r5r�_replacerrKrrrr8�s�


�z_BaseSelectorImpl.modifycCs|j��d|_dSr)r"�clearrEr#rrrr;
s

z_BaseSelectorImpl.closecCs|jSr)rEr#rrrr<sz_BaseSelectorImpl.get_mapcCs$	z|j|WStyYdSwr)r"r))rrrrr�_key_from_fds�z_BaseSelectorImpl._key_from_fdr)r-r.r/rr(r5r6r8r;r<rOrrrrrD�s

rDcs^eZdZ	�fdd�Zd
�fdd�	Z�fdd�Zejdkr#d
d	d
�Zne	j	Zd
dd�Z	�Z
S)�SelectSelectorcst���t�|_t�|_dSr)�superr�set�_readers�_writersr#��	__class__rrr&s
zSelectSelector.__init__Ncs@t��|||�}|t@r|j�|j�|t@r|j�|j�|Sr)rQr5rIrS�addrrJrTrKrUrrr5+szSelectSelector.registercs,t��|�}|j�|j�|j�|j�|Sr)rQr6rS�discardrrTrGrUrrr63szSelectSelector.unregisterZwin32cCs$t�||||�\}}}|||gfSr)r:)r�r�w�_r9�xrrr�_select:szSelectSelector._selectc	Cs�|durdnt|d�}g}z|�|j|jg|�\}}}Wnty'|YSwt|�}t|�}||BD]%}d}||vr@|tO}||vrH|tO}|�|�}|rY|�	|||j
@f�q4|S�Nr)�maxr]rSrT�InterruptedErrorrRrIrJrO�appendr)	rr9�readyrYrZr[rrrHrrrr:@s(�
�zSelectSelector.selectr)r-r.r/rr5r6�sys�platformr]r:�
__classcell__rrrUrrP#s
rPcs\eZdZ	dZdZdZ�fdd�Zd�fdd�	Z�fdd�Zd�fdd	�	Z	dd
d�Z
�ZS)
�_PollLikeSelectorNcst���|��|_dSr)rQr�
_selector_clsrr#rUrrr\�
z_PollLikeSelector.__init__csdt��|||�}d}|t@r||jO}|t@r||jO}z|j�|j|�W|St��|��r^)	rQr5rI�_EVENT_READrJ�_EVENT_WRITErrr6)rrrrrHZ
poller_eventsrUrrr5`s

�z_PollLikeSelector.registercs6t��|�}z
|j�|j�W|StyY|Swr)rQr6rr�OSErrorrGrUrrr6ns��z_PollLikeSelector.unregistercs�z
|j|�|�}Wntyt|�d��d�wd}||jkrLd}|t@r,||jO}|t@r5||jO}z
|j�	|j
|�Wn
t��|��d}||j
krSd}|rb|j||d�}||j|j
<|S)Nz is not registeredFrT)rr)r"r(r)rrIrirJrjrr8rrQr6rrM)rrrrrHZchangedZselector_eventsrUrrr8xs0�



z_PollLikeSelector.modifycCs�|durd}n|dkrd}nt�|d�}g}z|j�|�}Wnty*|YSw|D]+\}}d}||j@r=|tO}||j@rG|tO}|�	|�}|rX|�
|||j@f�q-|S)Nr�@�@)�math�ceilr�pollr`rirJrjrIrOrar)rr9rb�
fd_event_listr�eventrrHrrrr:�s,�
�z_PollLikeSelector.selectr)r-r.r/rgrirjrr5r6r8r:rerrrUrrfVs
rfroc@s eZdZ	ejZejZejZ	dS)�PollSelectorN)
r-r.r/r:rorg�POLLINri�POLLOUTrjrrrrrr�s

rr�epollcsBeZdZ	ejZejZejZ	dd�Z
ddd�Z�fdd�Z�ZS)	�
EpollSelectorcC�
|j��Sr�rr
r#rrrr
�rzEpollSelector.filenoNc	Cs�|durd}n|dkrd}n	t�|d�d}tt|j�d�}g}z	|j�||�}Wnty5|YSw|D]+\}}d}|tj	@rH|t
O}|tj@rR|tO}|�
|�}|rc|�|||j@f�q8|S)N���rrlg����MbP?r)rmrnr_r!r"rror`r:�EPOLLINrJ�EPOLLOUTrIrOrar)	rr9�max_evrbrprrqrrHrrrr:�s.�
�zEpollSelector.selectc�|j��t���dSr�rr;rQr#rUrrr;�rhzEpollSelector.closer)
r-r.r/r:rurgrzrir{rjr
r;rerrrUrrv�s
 rv�devpollcs8eZdZ	ejZejZejZ	dd�Z
�fdd�Z�ZS)�DevpollSelectorcCrwrrxr#rrrr
�rzDevpollSelector.filenocr}rr~r#rUrrr;�rhzDevpollSelector.close)
r-r.r/r:rrgrsrirtrjr
r;rerrrUrr��sr��kqueuecsVeZdZ	�fdd�Zdd�Zd�fdd�	Z�fdd	�Zdd
d�Z�fdd
�Z�Z	S)�KqueueSelectorcst���t��|_dSr)rQrr:r�rr#rUrrr�rhzKqueueSelector.__init__cCrwrrxr#rrrr
rzKqueueSelector.filenoNcs�t��|||�}z4|t@r t�|jtjtj�}|j�	|gdd�|t
@r:t�|jtjtj�}|j�	|gdd�W|SW|St��|��r^)
rQr5rIr:�keventr�KQ_FILTER_READZ	KQ_EV_ADDr�controlrJ�KQ_FILTER_WRITEr6)rrrrrH�kevrUrrr5s$����zKqueueSelector.registercs�t��|�}|jt@r*t�|jtjtj�}z|j	�
|gdd�Wn	ty)Ynw|jt@rPt�|jtj
tj�}z|j	�
|gdd�W|StyOY|Sw|Sr^)rQr6rrIr:r�rr�ZKQ_EV_DELETErr�rkrJr�)rrrHr�rUrrr6s,
��
���zKqueueSelector.unregisterc
Cs�|durdnt|d�}tt|j�d�}g}z
|j�d||�}Wnty*|YSw|D]-}|j}|j}d}|tj	kr@|t
O}|tjkrI|tO}|�
|�}	|	rZ|�|	||	j@f�q-|S)Nrr)r_r!r"rr�r`Zident�filterr:r�rIr�rJrOrar)
rr9r|rbZkev_listr�r�flagrrHrrrr:*s*�


�zKqueueSelector.selectcr}rr~r#rUrrr;CrhzKqueueSelector.closer)
r-r.r/rr
r5r6r:r;rerrrUrr��s
r�cCs\	tt|d�}|dur
dSz|�}|dkr|�d�WdS|��WdSty-YdSw)NFrorT)�getattrr:ror;rk)�methodrZselector_objrrr�_can_useHs
��r�) �abcrr�collectionsrZcollections.abcrrmr:rcrIrJrr�__doc__�version_inforrrrrr0rDrPrf�hasattrrrrvr�r�r�ZDefaultSelectorrrrr�<module>sP
~T3
Z

.
M

?>