%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/posixbase.cpython-312.pyc

�

Ϫ�f�S����dZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZmZmZmZmZmZmZmZmZmZddlmZmZdd	lmZmZdd
lm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'e	jPd
�Z)e	jPd�Z*	ddl+m,Z-e-Z,	ddlm/Z0e0Z/e!dk(Z1dZ2e1r
ddlm3Z3m4Z4dZ2e jj�r	ddl6Z6dZ2Gd�d�Z7eeee�Gd�de7e
��Z8Gd�d�Z9ee�Gd�de9e7��Z:e,�e/�	ee8e�e1r
ee8ee�e2r	ee8e�e;edd��	ee8e�dgZ<y#e.$rdZ,Y��wxYw#e.$rdZ/Y��wxYw#e.$rdZ6Y��wxYw)z
Posix reactor base class
�N)�Sequence)�classImplements�implementer)�error�tcp�udp)�ReactorBase)
�IHalfCloseableDescriptor�
IReactorFDSet�IReactorMulticast�IReactorProcess�IReactorSocket�IReactorSSL�IReactorTCP�IReactorUDP�IReactorUNIX�IReactorUNIXDatagram)�CONNECTION_DONE�CONNECTION_LOST)�failure�log)�platform�platformType�)�SignalHandling�_ChildSignalHandling�_IWaker�_MultiSignalHandling�_WakerzHandler has no fileno methodzFile descriptor lost)�tls)�ssl�posixF)�process�unixTc���eZdZdZej
ejej
��ejejej��ifd�Z	y)�_DisconnectSelectableMixinz>
    Mixin providing the C{_disconnectSelectable} method.
    c��|j|�|j|j�}|ri|rD|jtjk(r'tj|�r|j|�y|j|�|j|�y|j|�|jtj|��y)z�
        Utility function for disconnecting a selectable.

        Supports half-close notification, isRead should be boolean indicating
        whether error resulted from doRead().
        N)�removeReader�get�	__class__r�ConnectionDoner
�
providedBy�readConnectionLost�removeWriter�connectionLostr�Failure)�self�
selectable�why�isRead�faildict�fs      �</usr/lib/python3/dist-packages/twisted/internet/posixbase.py�_disconnectSelectablez0_DisconnectSelectableMixin._disconnectSelectableSs��� 	
���*�%��L�L����'�����M�M�U�%9�%9�9�,�7�7�
�C��-�-�a�0��!�!�*�-��)�)�!�,����j�)��%�%�g�o�o�c�&:�;�N)
�__name__�
__module__�__qualname__�__doc__rr+rr0�ConnectionLostr8�r9r7r&r&NsW���
� � �/�'�/�/�2F�%�2F�2F�2H�"I�� � �/�'�/�/�2F�%�2F�2F�2H�"I�
�<r9r&c�h��eZdZUdZdZdefd�Zd�Zdef�fd�Z	didddddfd	�Z
dd
�Z	dd�Zdd�Z
dd
�Zdd�Z	dd�Zer6ej&ej(ej*fZeej0ed<nej&ej(fZd�Zd�Z	dd�Zd d�Zd!d�Z	d!d�Zd d�Z d�Z!�xZ"S)"�PosixReactorBasez�
    A basis for reactors that use file descriptors.

    @ivar _childWaker: L{None} or a reference to the L{_SIGCHLDWaker}
        which is used to properly notice child process termination.
    N�returnc��t�S�N)r�r1s r7�
_wakerFactoryzPosixReactorBase._wakerFactory�s	���x�r9c���|jsV|j�|_|jj|j�|j	|j�yy)z�
        Install a `waker' to allow threads and signals to wake up the IO thread.

        We use the self-pipe trick (http://cr.yp.to/docs/selfpipe.html) to wake
        the reactor. On Windows we use a pair of sockets.
        N)�wakerrF�_internalReaders�add�	addReaderrEs r7�installWakerzPosixReactorBase.installWaker�sH���z�z��+�+�-�D�J��!�!�%�%�d�j�j�1��N�N�4�:�:�&�r9c���t�|��}tdk(r+t|t	|j
|j�f�S|S)zj
        Customize reactor signal handling to support child processes on POSIX
        platforms.
        r")�super�_signalsFactoryrrr�_addInternalReader�_removeInternalReader)r1�baseHandlingr*s  �r7rOz PosixReactorBase._signalsFactory�sS���
�w�.�0���7�"�'�!�(��/�/��2�2��	�
�

��r9r?rc
�~�tdk(rI|r*|	�td��tj|||||||||�	Stj|||||||||	�	Stdk(rX|�td��|�td��|rtd��|	rtd��t
rdd	lm}
|
||||||�Std
��td��)Nr"z1Using childFDs is not supported with usePTY=True.�win32z,Setting UID is unsupported on this platform.z,Setting GID is unsupported on this platform.z1The usePTY parameter is not supported on Windows.z1Customizing childFDs is not supported on Windows.r)�Processz:spawnProcess not available since pywin32 is not installed.z0spawnProcess only available on Windows or POSIX.)r�
ValueErrorr#�
PTYProcessrU�win32process�twisted.internet._dumbwin32proc�NotImplementedError)r1�processProtocol�
executable�args�env�path�uid�gid�usePTY�childFDsrUs           r7�spawnProcesszPosixReactorBase.spawnProcess�s���7�"���'�$�K����)�)��*�d�C����S�RX�����������#����
�
��W�
$��� �!O�P�P��� �!O�P�P�� �!T�U�U�� �!T�U�U��C��t�_�j�$��T�R�R�)�P���&�B��
r9c�X�tj|||||�}|j�|S)z�Connects a given L{DatagramProtocol} to the given numeric UDP port.

        @returns: object conforming to L{IListeningPort}.
        )r�Port�startListening)r1�port�protocol�	interface�
maxPacketSize�ps      r7�	listenUDPzPosixReactorBase.listenUDP�s+��

�H�H�T�8�Y�
�t�D��	�����r9c�Z�tj||||||�}|j�|S)z�Connects a given DatagramProtocol to the given numeric UDP port.

        EXPERIMENTAL.

        @returns: object conforming to IListeningPort.
        )r�
MulticastPortrg)r1rhrirjrk�listenMultiplerls       r7�listenMulticastz PosixReactorBase.listenMulticast�s4��
����(�I�}�d�N�
��	
�����r9c�r�tsJd��tj|||||�}|j�|S�N�UNIX support is not present)�unixEnabledr$�	Connector�connect)r1�address�factory�timeout�checkPID�cs      r7�connectUNIXzPosixReactorBase.connectUNIXs4���9�9�9�{��N�N�7�G�W�d�H�E��	�	�	���r9c�t�tsJd��tj||||||�}|j�|Srs)rur$rfrg)r1rxry�backlog�mode�wantPIDrls       r7�
listenUNIXzPosixReactorBase.listenUNIXs9���9�9�9�{��I�I�g�w���t�W�E��	�����r9c�r�tsJd��tj|||||�}|j�|S)z�
        Connects a given L{DatagramProtocol} to the given path.

        EXPERIMENTAL.

        @returns: object conforming to L{IListeningPort}.
        rt)rur$�DatagramPortrg)r1rxrirkr�rls      r7�listenUNIXDatagramz#PosixReactorBase.listenUNIXDatagrams;���9�9�9�{����g�x���d�K��	�����r9c�t�tsJd��tj||||||�}|j�|S)zd
        Connects a L{ConnectedDatagramProtocol} instance to a path.

        EXPERIMENTAL.
        rt)rur$�ConnectedDatagramPortrg)r1rxrirkr��bindAddressrls       r7�connectUNIXDatagramz$PosixReactorBase.connectUNIXDatagramsB���9�9�9�{��&�&��X�}�d�K��
��	
�����r9�_supportedAddressFamiliesc�&�||jvrtj|��tr5|tj
k(r"tjj|||�}n"tjj||||�}|j�|S)a0
        Create a new L{IListeningPort} from an already-initialized socket.

        This just dispatches to a suitable port implementation (eg from
        L{IReactorTCP}, etc) based on the specified C{addressFamily}.

        @see: L{twisted.internet.interfaces.IReactorSocket.adoptStreamPort}
        )r�r�UnsupportedAddressFamilyru�socket�AF_UNIXr$rf�_fromListeningDescriptorrrg)r1�fileDescriptor�
addressFamilyryrls     r7�adoptStreamPortz PosixReactorBase.adoptStreamPort8sy���� >� >�>��0�0��?�?��=�F�N�N�:��	�	�2�2�4���Q�A����1�1��n�m�W��A�	
�����r9c��||jvrtj|��tr4|tj
k(r!tjj|||�Stjj||||�S)zg
        @see:
            L{twisted.internet.interfaces.IReactorSocket.adoptStreamConnection}
        )
r�rr�rur�r�r$�Server�_fromConnectedSocketr)r1r�r�rys    r7�adoptStreamConnectionz&PosixReactorBase.adoptStreamConnectionMsj��
�� >� >�>��0�0��?�?��=�F�N�N�:��;�;�3�3�N�G�T�R�R��:�:�2�2��
�w���
r9c���|tjtjfvrtj|��t
jj|||||��}|j�|S)N)rk)	r��AF_INET�AF_INET6rr�rrfr�rg)r1r�r�rirkrls      r7�adoptDatagramPortz"PosixReactorBase.adoptDatagramPort\sa��������� A�A��0�0��?�?��H�H�-�-��.�-���
.�
��	
�����r9c�X�tj|||||�}|j�|SrD)rrfrg)r1rhryrrjrls      r7�	listenTCPzPosixReactorBase.listenTCPjs)���H�H�T�7�G�Y��=��	�����r9c�Z�tj||||||�}|j�|SrD)rrvrw)r1�hostrhryrzr�r|s       r7�
connectTCPzPosixReactorBase.connectTCPos(���M�M�$��g�w��T�J��	�	�	���r9c	���t�,tj|d|�}|j|||||�St�-tj	|||||||�}|j�|SJd��)NT�SSL support is not present)r �TLSMemoryBIOFactoryr�r!rvrw)	r1r�rhry�contextFactoryrzr��
tlsFactoryr|s	         r7�
connectSSLzPosixReactorBase.connectSSLvsq���?��0�0���w�O�J��?�?�4��z�7�K�P�P�
�_��
�
��d�G�^�W�k�4��A�
�I�I�K��H�6�6�6�5r9c���t�4tj|d|�}|j||||�}d|_|St�,tj||||||�}|j
�|SJd��)NF�TLSr�)r r�r��_typer!rfrg)r1rhryr�rrjr�rls        r7�	listenSSLzPosixReactorBase.listenSSL�st���?��0�0����P�J��>�>�$�
�G�Y�G�D��D�J��K�
�_�����w����D�Q�A�
�����H�6�6�6�5r9c���t|�|jz
}|D]}|j|��t|�}|D]}|j|��t	||z�S)ag
        Remove all readers and writers, and list of removed L{IReadDescriptor}s
        and L{IWriteDescriptor}s.

        Meant for calling from subclasses, to implement removeAll, like::

          def removeAll(self):
              return self._removeAll(self._reads, self._writes)

        where C{self._reads} and C{self._writes} are iterables.
        )�setrIr(r.�list)r1�readers�writers�removedReaders�reader�removedWriters�writers       r7�
_removeAllzPosixReactorBase._removeAll�so���W���(=�(=�=��$�	&�F����f�%�	&��W���$�	&�F����f�%�	&��N�^�3�4�4r9)�� )r�r�F)�r)�2�r)r�r�)r�r�N)r�)r�r�)r�N)#r:r;r<r=�_childWakerrrFrLrrOrdrmrqr}r�r�r�rur�r�r�r�r�r�
AddressFamily�__annotations__r�r�r�r�r�r�r�r��
__classcell__)r*s@r7rArAts������K��w��
'����<��
�����6�t�PU�
�"���NR�
�"��N�N��O�O��N�N�E
�!�8�F�,@�,@�#A�	
�
�N�N��O�O�%
�!�
�*
� FJ�
��
�LP�
7�7�5r9rAc��eZdZdZd�Zy)�_PollLikeMixina�
    Mixin for poll-like reactors.

    Subclasses must define the following attributes::

      - _POLL_DISCONNECTED - Bitmask for events indicating a connection was
        lost.
      - _POLL_IN - Bitmask for events indicating there is input to read.
      - _POLL_OUT - Bitmask for events indicating output can be written.

    Must be mixed in to a subclass of PosixReactorBase (for
    _disconnectSelectable).
    c���d}d}||jzr-||jzs||jvr	d}t}nft}n_	|j�dk(rt}nD||jzr|j�}d}|s!||jzr|j�}d}|r|j|||�yy#t$r.tj�d}tj�Y�MwxYw)zg
        fd is available for read or write, do the work and raise errors if
        necessary.
        NFT���r)�_POLL_DISCONNECTED�_POLL_IN�_readsrr�fileno�_NO_FILEDESC�doRead�	_POLL_OUT�doWrite�
BaseException�sys�exc_infor�errr8)r1r2�fd�eventr3�inReads      r7�_doReadOrWritez_PollLikeMixin._doReadOrWrite�s���
�����4�*�*�*�E�D�M�M�4I��T�[�[� �
��%��&��
��$�$�&�"�,�'�C��t�}�}�,�(�/�/�1��!%���5�4�>�>�#9�)�0�0�2��!&����&�&�z�3��?���!�
��l�l�n�Q�'�����	�	
�s�AB7�74C.�-C.N)r:r;r<r=r�r?r9r7r�r��s
���7@r9r�c�d�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�_ContinuousPollinga�
    Schedule reads and writes based on the passage of time, rather than
    notification.

    This is useful for supporting polling filesystem files, which C{epoll(7)}
    does not support.

    The implementation uses L{_PollLikeMixin}, which is a bit hacky, but
    re-implementing and testing the relevant code yet again is unappealing.

    @ivar _reactor: The L{EPollReactor} that is using this instance.

    @ivar _loop: A C{LoopingCall} that drives the polling, or L{None}.

    @ivar _readers: A C{set} of C{FileDescriptor} objects that should be read
        from.

    @ivar _writers: A C{set} of C{FileDescriptor} objects that should be
        written to.
    r��c�\�||_d|_t�|_t�|_yrD)�_reactor�_loopr��_readers�_writers)r1�reactors  r7�__init__z_ContinuousPolling.__init__s"����
���
����
����
r9c�Z�|js|jre|j�Xddlm}m}||j�|_|j|j_|jj|d��yy|jr"|jj�d|_yy)zh
        Start or stop a C{LoopingCall} based on whether there are readers and
        writers.
        Nr)�_EPSILON�LoopingCallF)�now)r�r�r��twisted.internet.taskr�r��iterater��clock�start�stop)r1r�r�s   r7�
_checkLoopz_ContinuousPolling._checkLoops��
�=�=�D�M�M��z�z�!�G�(����6��
�#'�=�=��
�
� ��
�
� � ��u� �5�"��Z�Z��J�J�O�O���D�J�r9c���t|j�D]}|j|||j��!t|j�D]}|j|||j
��!y)zX
        Call C{doRead} and C{doWrite} on all readers and writers respectively.
        N)r�r�r�r�r�r�)r1r�r�s   r7r�z_ContinuousPolling.iterate&sb���4�=�=�)�	?�F�������
�
�>�	?��4�=�=�)�	@�F���������?�	@r9c�Z�|jj|�|j�y)zU
        Add a C{FileDescriptor} for notification of data available to read.
        N)r�rJr��r1r�s  r7rKz_ContinuousPolling.addReader/� ��	
�
�
���&�!����r9c�Z�|jj|�|j�y)zV
        Add a C{FileDescriptor} for notification of data available to write.
        N)r�rJr��r1r�s  r7�	addWriterz_ContinuousPolling.addWriter6r�r9c�z�	|jj|�|j�y#t$rYywxYw)zY
        Remove a C{FileDescriptor} from notification of data available to read.
        N)r��remove�KeyErrorr�r�s  r7r(z_ContinuousPolling.removeReader=s9��	��M�M� � ��(�	
������	��	���.�	:�:c�z�	|jj|�|j�y#t$rYywxYw)zb
        Remove a C{FileDescriptor} from notification of data available to
        write.
        N)r�r�r�r�r�s  r7r.z_ContinuousPolling.removeWriterGs9��
	��M�M� � ��(�	
������	��	�r�c��t|j|jz�}|jj�|jj�|S)z1
        Remove all readers and writers.
        )r�r�r��clear)r1�results  r7�	removeAllz_ContinuousPolling.removeAllRsB���d�m�m�d�m�m�3�4��	
�
�
�����
�
�����
r9c�,�t|j�S)z/
        Return a list of the readers.
        )r�r�rEs r7�
getReadersz_ContinuousPolling.getReaders]����D�M�M�"�"r9c�,�t|j�S)z/
        Return a list of the writers.
        )r�r�rEs r7�
getWritersz_ContinuousPolling.getWriterscr�r9c��||jvS)aj
        Checks if the file descriptor is currently being observed for read
        readiness.

        @param fd: The file descriptor being checked.
        @type fd: L{twisted.internet.abstract.FileDescriptor}
        @return: C{True} if the file descriptor is being observed for read
            readiness, C{False} otherwise.
        @rtype: C{bool}
        )r��r1r�s  r7�	isReadingz_ContinuousPolling.isReadingi����T�]�]�"�"r9c��||jvS)al
        Checks if the file descriptor is currently being observed for write
        readiness.

        @param fd: The file descriptor being checked.
        @type fd: L{twisted.internet.abstract.FileDescriptor}
        @return: C{True} if the file descriptor is being observed for write
            readiness, C{False} otherwise.
        @rtype: C{bool}
        )r�r�s  r7�	isWritingz_ContinuousPolling.isWritingvr�r9N)r:r;r<r=r�r�r�r�r�r�rKr�r(r.r�r�r�r�rr?r9r7r�r��sV���,���H��I���$@����	�	�#�#�#�#r9r��fromfd)=r=r�r��typingr�zope.interfacerr�twisted.internetrrr�twisted.internet.baser	�twisted.internet.interfacesr
rrr
rrrrrr�twisted.internet.mainrr�twisted.pythonrr�twisted.python.runtimerr�_signalsrrrrr�ConnectionFdescWentAway�
_NO_FILENOr��twisted.protocolsr �_tls�ImportErrorr!�_sslru�processEnabledr#r$�	isWindowsrXr&rAr�r��getattr�__all__r?r9r7�<module>rs���
�
�
��7�,�,�-����C�'�9���+�U�
*�
*�+I�
J�
�,�u�,�,�-C�D���-��C��,��C��g�%�����.��N��8��������
#<�#<�L
�[�+�'8�9�q5�1�;�q5�:�q5�h	F@�F@�R
�]��N#��)C�N#��N#�b�?�c�o��$�k�2���$�l�4H�I���$�o�6�
�6�8�T�"�.��$�n�5��
���{��
�C�����
�C���&�����s6�E�E�E!�E�E�E�E�!E+�*E+

Zerion Mini Shell 1.0