%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/__pycache__/selectors.cpython-312.pyc

�

���f�L��t�dZddlmZmZddlmZddlmZddlZddl	Z	ddl
Z
dZdZd�Z
ed	gd
��Zde_dej_d
ej _dej"_dej$_Gd�de�ZGd�de��ZGd�de�ZGd�de�ZGd�de�Zee	d�rGd�de�Zee	d�rGd�d e�Zee	d!�rGd"�d#e�Zee	d$�rGd%�d&e�Zd'�Zed$�reZyed�reZyed!�reZyed�reZyeZy)(z|Selectors module.

This module allows high-level and efficient I/O multiplexing, built upon the
`select` module primitives.
�)�ABCMeta�abstractmethod)�
namedtuple)�MappingN��c��t|t�r|}n	t|j��}|dkrtdj
|���|S#ttt
f$rtdj
|��d�wxYw)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�fds  � /usr/lib/python3.12/selectors.py�_fileobj_to_fdrs����'�3��
��	?��W�^�^�%�&�B�
�A�v��6�=�=�b�A�B�B�
�I���	�:�6�	?��$�$*�F�7�O�5�:>�
?�	?�s�A�0A?�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.zvOptional opaque data associated to this file object.
For example, this could be used to store a per-client session ID.c�(�eZdZdZd�Zd�Zd�Zd�Zy)�_SelectorMappingz)Mapping of file objects to selector keys.c��||_y�N)�	_selector)�self�selectors  r�__init__z_SelectorMapping.__init__?s	��!���c�@�t|jj�Sr)�lenr�
_fd_to_key�rs r�__len__z_SelectorMapping.__len__Bs���4�>�>�,�,�-�-r c��	|jj|�}|jj|S#t$rtdj	|��d�wxYw�N�{!r} is not registered)r�_fileobj_lookupr#�KeyErrorr)rrrs   r�__getitem__z_SelectorMapping.__getitem__Es[��	O����/�/��8�B��>�>�,�,�R�0�0���	O��3�:�:�7�C�D�$�N�	O�s	�36�%Ac�@�t|jj�Sr)�iterrr#r$s r�__iter__z_SelectorMapping.__iter__Ls���D�N�N�-�-�.�.r N)�__name__�
__module__�__qualname__�__doc__rr%r+r.�r rrr<s��3�"�.�O�/r rc�t�eZdZdZedd��Zed��Zdd�Zedd��Zd�Z	d�Z
ed	��Zd
�Zd�Z
y)
�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.
    Nc��t�)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
        ��NotImplementedError�rrrrs    r�registerzBaseSelector.register_s
��*"�!r c��t�)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)
        r7)rrs  r�
unregisterzBaseSelector.unregisterv�
��""�!r c�J�|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:r9s    r�modifyzBaseSelector.modify�s#��	
���� ��}�}�W�f�d�3�3r c��t�)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
        r7)r�timeouts  r�selectzBaseSelector.select�r=r c��y)zmClose the selector.

        This must be called to make sure that any underlying resource is freed.
        Nr3r$s r�closezBaseSelector.close�s��
	
r c��|j�}|�td��	||S#t$rtdj|��d�wxYw)zzReturn the key associated to a registered file object.

        Returns:
        SelectorKey for this file object
        NzSelector is closedr()�get_map�RuntimeErrorr*r)rr�mappings   r�get_keyzBaseSelector.get_key�s[���,�,�.���?��3�4�4�	O��7�#�#���	O��3�:�:�7�C�D�$�N�	O�s	�$�%A	c��t�)z2Return a mapping of file objects to selector keys.r7r$s rrFzBaseSelector.get_map�s
��"�!r c��|Srr3r$s r�	__enter__zBaseSelector.__enter__�s���r c�$�|j�yr)rD)r�argss  r�__exit__zBaseSelector.__exit__�s���
�
�r r)r/r0r1r2rr:r<r?rBrDrIrFrLrOr3r rr5r5Psq����"��"�,�"��"�$4�"�"��"�$
�O��"��"��r r5)�	metaclassc�D�eZdZdZd�Zd�Zdd�Zd�Zdd�Zd�Z	d	�Z
d
�Zy)�_BaseSelectorImplzBase selector implementation.c�2�i|_t|�|_yr)r#r�_mapr$s rrz_BaseSelectorImpl.__init__�s�����$�T�*��	r c��	t|�S#t$r?|jj�D] }|j|us�|j
ccYS�wxYw)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.
        )rrr#�valuesrr�rr�keys   rr)z!_BaseSelectorImpl._fileobj_lookup�sW��	�!�'�*�*���	����-�-�/�
"���;�;�'�)��6�6�M�
"�
�
	�s�

�4A�A�ANc�F�|r|ttzzrtdj|���t	||j|�||�}|j|jvr%tdj||j���||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered)	�
EVENT_READ�EVENT_WRITErrrr)rr#r*�rrrrrXs     rr:z_BaseSelectorImpl.register�s����F�z�K�'?�%@�@��3�:�:�6�B�C�C��'�4�#7�#7��#@�&�$�O���6�6�T�_�_�$��?�"�F�7�C�F�F�3�5�
5�#&���������
r c��	|jj|j|��}|S#t$rtdj	|��d�wxYwr')r#�popr)r*rrWs   rr<z_BaseSelectorImpl.unregister�sZ��	O��/�/�%�%�d�&:�&:�7�&C�D�C��
���	O��3�:�:�7�C�D�$�N�	O�s	�*.�%Ac�r�	|j|j|�}||jk7r&|j|�|j
|||�}|S||jk7r+|j|��}||j|j<|S#t$rtdj|��d�wxYw)Nr()r)
r#r)r*rrr<r:r�_replacerr\s     rr?z_BaseSelectorImpl.modify�s���	O��/�/�$�"6�"6�w�"?�@�C��S�Z�Z���O�O�G�$��-�-����6�C�
�
�	�S�X�X�
��,�,�D�,�)�C�&)�D�O�O�C�F�F�#��
���	O��3�:�:�7�C�D�$�N�	O�s�B�%B6c�F�|jj�d|_yr)r#�clearrTr$s rrDz_BaseSelectorImpl.closes����������	r c��|jSr)rTr$s rrFz_BaseSelectorImpl.get_maps���y�y�r c�@�	|j|S#t$rYywxYw)z�Return the key associated to a given file descriptor.

        Parameters:
        fd -- file descriptor

        Returns:
        corresponding key, or None if not found
        N)r#r*)rrs  r�_key_from_fdz_BaseSelectorImpl._key_from_fds(��	��?�?�2�&�&���	��	�s��	�r)r/r0r1r2rr)r:r<r?rDrFrer3r rrRrR�s-��'�+��&�����r rRc���eZdZdZ�fd�Zd�fd�	Z�fd�Zejdk(rdd�Z	ne
jZ	dd�Z
�xZS)	�SelectSelectorzSelect-based selector.c�^��t�|��t�|_t�|_yr)�superr�set�_readers�_writers�r�	__class__s �rrzSelectSelector.__init__%s ���
�������
����
r c����t�|�|||�}|tzr%|jj	|j
�|tzr%|jj	|j
�|Sr)rir:rZrk�addrr[rl)rrrrrXrns     �rr:zSelectSelector.register*sW����g��w���5���J���M�M���c�f�f�%��K���M�M���c�f�f�%��
r c���t�|�|�}|jj|j�|j
j|j�|Sr)rir<rk�discardrrl�rrrXrns   �rr<zSelectSelector.unregister2sC����g� ��)���
�
���c�f�f�%��
�
���c�f�f�%��
r �win32c�J�tj||||�\}}}|||zgfSr)rB)r�r�w�_rA�xs      r�_selectzSelectSelector._select9s,���m�m�A�q�!�W�5�G�A�q�!��a�!�e�R�<�r c��|�dnt|d�}g}	|j|j|jg|�\}}}t|�}t|�}||zD]R}d}||vr	|tz}||vr	|tz}|j|�}|s�3|j|||jzf��T|S#t$r|cYSwxYw�Nr)�maxrzrkrl�InterruptedErrorrjrZr[re�appendr)	rrA�readyrvrwrxrrrXs	         rrBzSelectSelector.select?s���!�/�$�s�7�A�����	��l�l�4�=�=�$�-�-��W�M�G�A�q�!�
��F����F���a�%�		9�B��F��Q�w��*�$���Q�w��+�%���#�#�B�'�C�����c�6�C�J�J�#6�7�8�		9���� �	��L�	�s�,B2�2C�?Cr)r/r0r1r2rr:r<�sys�platformrzrB�
__classcell__�rns@rrgrg"s8��� ��
���|�|�w��	 ��-�-��r rgc�X��eZdZdZdZdZdZ�fd�Zd�fd�	Z�fd�Z	d�fd�	Z
dd�Z�xZS)	�_PollLikeSelectorz<Base class shared between poll, epoll and devpoll selectors.Nc�L��t�|��|j�|_yr)rir�
_selector_clsrrms �rrz_PollLikeSelector.__init__[s���
�����+�+�-��r c���t�|�|||�}d}|tzr||jz}|tzr||j
z}	|jj|j|�|S#t�|�!|��xYwr|)	rir:rZ�_EVENT_READr[�_EVENT_WRITErrr<)rrrrrX�
poller_eventsrns      �rr:z_PollLikeSelector.register_s�����g��w���5���
��J���T�-�-�-�M��K���T�.�.�.�M�	��N�N�#�#�C�F�F�M�:��
��	��G��w�'��s�&A.�.Bc���t�|�|�}	|jj|j�|S#t$rY|SwxYwr)rir<rr�OSErrorrss   �rr<z_PollLikeSelector.unregistermsO����g� ��)��	��N�N�%�%�c�f�f�-�
�
��	�	�
��
�		�s�%9�	A�Ac���	|j|j|�}d}||jk7r[d}|tzr||j
z}|tzr||jz}	|jj|j|�d}||jk7rd}|r,|j||��}||j|j<|S#t$rt|�d��d�wxYw#t�|�1|��xYw)Nz is not registeredFrT)rr)r#r)r*rrZr�r[r�rr?rrir<rr`)rrrrrX�changed�selector_eventsrns       �rr?z_PollLikeSelector.modifyws	���	G��/�/�$�"6�"6�w�"?�@�C����S�Z�Z���O��
�"��4�#3�#3�3����#��4�#4�#4�4��
����%�%�c�f�f�o�>��G��3�8�8���G���,�,�f�4�,�8�C�&)�D�O�O�C�F�F�#��
��-�	G��g�[�(:�;�<�$�F�	G��
���"�7�+��s�C�%&C*�C'�*C<c��|�d}n |dkrd}ntj|dz�}g}	|jj|�}|D]m\}}d}||j
zr	|tz}||jzr	|tz}|j|�}|s�N|j|||jzf��o|S#t$r|cYSwxYw)Nr�@�@)�math�ceilr�pollr~r�r[r�rZrerr)rrAr��
fd_event_listr�eventrrXs        rrBz_PollLikeSelector.select�s����?��G�
��\��G��i�i��#�
�.�G���	� �N�N�/�/��8�M�'�		9�I�B���F���(�(�(�(��+�%����)�)�)�)��*�$���#�#�B�'�C�����c�6�C�J�J�#6�7�8�		9���� �	��L�	�s�B8�8C�Cr)
r/r0r1r2r�r�r�rr:r<r?rBr�r�s@rr�r�Us.���F��M��K��L�.����6r r�r�c�X�eZdZdZej
ZejZejZ
y)�PollSelectorzPoll-based selector.N)r/r0r1r2rBr�r��POLLINr��POLLOUTr�r3r rr�r��s ��"����
��m�m���~�~�r r��epollc�x��eZdZdZej
ZejZejZ
d�Zdd�Z�fd�Z�xZ
S)�
EpollSelectorzEpoll-based selector.c�6�|jj�Sr�rrr$s rrzEpollSelector.fileno�����>�>�(�(�*�*r c���|�d}n#|dkrd}ntj|dz�dz}tt|j�d�}g}	|j
j
||�}|D]u\}}d}|tjzr	|tz}|tjzr	|tz}|j|�}|s�V|j|||jzf��w|S#t$r|cYSwxYw)N���rr�g����MbP?r)r�r�r}r"r#rr�r~rB�EPOLLINr[�EPOLLOUTrZrerr)	rrA�max_evr�r�rr�rrXs	         rrBzEpollSelector.select�s��������A�����)�)�G�c�M�2�T�9��
��T�_�_�-�q�1�F��E�
� $��� 3� 3�G�V� D�
�+�	
=�	��E����F�N�N�?�*��k�)�F��F�O�O�+�+��j�(�F��'�'��+����L�L�#�v��
�
�':�!;�<�	
=��L��$�
���
�s�C#�#C1�0C1c�V��|jj�t�|��yr�rrDrirms �rrDzEpollSelector.close������N�N� � �"��G�M�Or r)r/r0r1r2rBr�r�r�r�r�r�rrDr�r�s@rr�r��s6���#����
��n�n������	+�	�@	�	r r��devpollc�p��eZdZdZej
ZejZejZ
d�Z�fd�Z�xZ
S)�DevpollSelectorzSolaris /dev/poll selector.c�6�|jj�Srr�r$s rrzDevpollSelector.fileno�r�r c�V��|jj�t�|��yrr�rms �rrDzDevpollSelector.close�r�r )r/r0r1r2rBr�r�r�r�r�r�rrDr�r�s@rr�r��s0���)����
��m�m���~�~��	+�	�	r r��kqueuec�P��eZdZdZ�fd�Zd�Zd�fd�	Z�fd�Zdd�Z�fd�Z	�xZ
S)	�KqueueSelectorzKqueue-based selector.c�b��t�|��tj�|_d|_yr|)rirrBr�r�_max_eventsrms �rrzKqueueSelector.__init__�s#����G���#�]�]�_�D�N� �D�r c�6�|jj�Srr�r$s rrzKqueueSelector.filenor�r c�:��t�|�|||�}	|tzrptj|j
tjtj�}|jj|gdd�|xjdz
c_
|tzrptj|j
tjtj�}|jj|gdd�|xjdz
c_
|S#t�|�5|��xYw�Nrr)rir:rZrB�keventr�KQ_FILTER_READ�	KQ_EV_ADDr�controlr�r[�KQ_FILTER_WRITEr<)rrrrrX�kevrns      �rr:zKqueueSelector.registers�����'�"�7�F�D�9�C�

��J�&� �-�-�����0E�0E�(.�(8�(8�:�C��N�N�*�*�C�5�!�Q�7��$�$��)�$��K�'� �-�-�����0F�0F�(.�(8�(8�:�C��N�N�*�*�C�5�!�Q�7��$�$��)�$��J��
���"�7�+��s�C2D�Dc�x��t�|�|�}|jtzrqt	j
|jtjtj�}|xjdzc_		|jj|gdd�|jtzrst	j
|jtjtj�}|xjdzc_		|jj|gdd�|S|S#t$rY��wxYw#t$rY|SwxYw)Nrr)rir<rrZrBr�rr��KQ_EV_DELETEr�rr�r�r[r�)rrrXr�rns    �rr<zKqueueSelector.unregisters����'�$�W�-�C��z�z�J�&��m�m�C�F�F�F�,A�,A�$*�$7�$7�9��� � �A�%� ���N�N�*�*�C�5�!�Q�7�
�z�z�K�'��m�m�C�F�F�F�,B�,B�$*�$7�$7�9��� � �A�%� ���N�N�*�*�C�5�!�Q�7��J�3�J�����������J��s$�7D�;D,�	D)�(D)�,	D9�8D9c���|�dnt|d�}|jxsd}g}	|jjd||�}|D]�}|j
}|j}d}|tjk(r	|tz}|tjk(r	|tz}|j|�}	|	s�i|j|	||	jzf���|S#t$r|cYSwxYwr�)r}r�rr�r~�ident�filterrBr�rZr�r[rerr)
rrAr�r��kev_listr�r�flagrrXs
          rrBzKqueueSelector.select.s���%�o�d�3�w��?�G��%�%�*��F��E�
��>�>�1�1�$���H�� �
=���Y�Y���z�z�����6�0�0�0��j�(�F��6�1�1�1��k�)�F��'�'��+����L�L�#�v��
�
�':�!;�<�
=��L��$�
���
�s�C�C�Cc�V��|jj�t�|��yrr�rms �rrDzKqueueSelector.closeGr�r r)r/r0r1r2rrr:r<rBrDr�r�s@rr�r��s)���$�	!�
	+�	�$	�.	�2	�	r r�c��tt|d�}|�y	|�}|dk(r|jd�y|j�y#t$rYywxYw)zJCheck if we can use the selector depending upon the
    operating system. NFr�rT)�getattrrBr�rDr�)�methodr�selector_objs   r�_can_user�Lse���v�v�t�,�H����
��z���V�����a� ��
��� �������s�A�A�	A�A)r2�abcrr�collectionsr�collections.abcrr�rBr�rZr[rrrrrrrr5rRrgr��hasattrr�r�r�r�r��DefaultSelectorr3r r�<module>r�ss���(�"�#��
�
��
����2��(K�L�����
8�����6�����R�����E�����/�w�/�({�W�{�|Q��Q�h0�&�0�fW�)�W�t�6�6��&�(�&��6�7��+�)�+�\�6�9���+���6�8��O�*�O�d�4�H��$�O�
�g��#�O�
�i��%�O�
�f��"�O�$�Or 

Zerion Mini Shell 1.0