%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f���dZddlZddlZddlZddlmZddlmZmZmZm	Z	mZddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZ	ddlmZmZmZddlmZdd
lmZddlm Z ddl!m"Z"m#Z#m$Z$	eee�jQ�dZ)dZ*Gd�de�Z.Gd�de�Z/y#e%$rejLdk(r�dZ'Y�LwxYw#e+$rZ,dZ)e-e,�Z*YdZ,[,�HdZ,[,wwxYw)z,
Tests for L{twisted.internet.iocpreactor}.
�N)�array)�AF_INET�AF_INET6�SOCK_STREAM�
SOL_SOCKET�socket)�pack)�skipIf)�verifyClass)�
IPushProducer)�msg)�TestCase)�iocpsupport�tcp�udp)�
FileHandle)�SO_UPDATE_ACCEPT_CONTEXT)�IReadWriteHandle)�EVENTS_PER_LOOP�
KEY_NORMAL�IOCPReactor�win32z%This test only applies to IOCPReactorF�Tc�:�eZdZdZd�Zd�Zeee�d��Z	y)�SupportTestszn
    Tests for L{twisted.internet.iocpreactor.iocpsupport}, low-level reactor
    implementation helpers.
    c
��td|���t|t�}|j|j�|jd�|j
d�t|t�}|j|j�|jd�	|j||j�df�t|t�}|j|j�tdd�}|j!dt#j$|j'�|j'�|d��t)t+d	��D]7}	|j-t.t0t3d
|j'���n|j!||j;�dd
|j�dd
ft#j<|j'�|��y#t$rE}|j|jtjtjf�Yd}~��ld}~wwxYw#t$r.}	|	jt5td�k7r�|dk(r�Yd}	~	nd}	~	wwxYwt7j8d���6)a�
        Create a C{SOCK_STREAM} connection to localhost using a socket with an
        address family of C{family} and assert that the result of
        L{iocpsupport.get_accept_addrs} is consistent with the result of
        C{socket.getsockname} and C{socket.getpeername}.

        A port starts listening (is bound) at the low-level socket without
        calling accept() yet.
        A client is then connected.
        After the client is connected IOCP accept() is called, which is the
        target of these tests.

        Most of the time, the socket is ready instantly, but sometimes
        the socket is not ready right away after calling IOCP accept().
        It should not take more than 5 seconds for a socket to be ready, as
        the client connection is already made over the loopback interface.

        These are flaky tests.
        Tweak the failure rate by changing the number of retries and the
        wait/sleep between retries.

        If you will need to update the retries to wait more than 5 seconds
        for the port to be available, then there might a bug in the code and
        not the test (or a very, very busy VM running the tests).
        z	family = )rr�FN�Bsr��P�WSAENOTCONNg�������?�)r
rr�
addCleanup�close�bind�listen�setblocking�connect�getsockname�OSError�assertIn�errno�EINPROGRESS�EWOULDBLOCKr�assertEqual�_iocp�accept�fileno�reversed�range�
setsockoptrrr	�getattr�time�sleep�getpeername�get_accept_addrs)
�self�family�	localhost�port�client�e�server�buff�attemptsRemaining�socketErrors
          �A/usr/lib/python3/dist-packages/twisted/internet/test/test_iocp.py�_acceptAddressTestzSupportTests._acceptAddressTest7s��4	�i��z�"�#��f�k�*������
�
�#��	�	�'�����A�����,��������%����5�!�	K��N�N�I�t�'7�'7�'9�!�'<�=�>����,��������%��S�+�&������E�L�L������
�
���t�T�U�!)�%��(�!3�	��
��!�!�� 8�$�s�D�K�K�M�:R���	�B	
���
�V�'�'�)�"�1�-�v�/A�/A�/C�B�Q�/G�H��"�"�6�=�=�?�D�9�	
��S�	K��M�M�!�'�'�E�$5�$5�u�7H�7H�#I�J�J��	K��0�

��$�$���}�(E�E��%��)��*��

��
�J�J�s�Os0�$G �3H1� 	H.�):H)�)H.�1	I(�:$I#�#I(c�0�|jtd�y)a
        L{iocpsupport.get_accept_addrs} returns a three-tuple of address
        information about the socket associated with the file descriptor passed
        to it.  For a connection using IPv4:

          - the first element is C{AF_INET}
          - the second element is a two-tuple of a dotted decimal notation IPv4
            address and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        z	127.0.0.1N)rFr�r;s rE�test_ipv4AcceptAddressz#SupportTests.test_ipv4AcceptAddress�s��	
�����5�c�0�|jtd�y)a�
        Like L{test_ipv4AcceptAddress}, but for IPv6 connections.
        In this case:

          - the first element is C{AF_INET6}
          - the second element is a two-tuple of a hexadecimal IPv6 address
            literal and a port number giving the peer address of the connection
          - the third element is the same type giving the host address of the
            connection
        z::1N)rFrrHs rE�test_ipv6AcceptAddressz#SupportTests.test_ipv6AcceptAddress�s��	
����%�0rJN)
�__name__�
__module__�__qualname__�__doc__rFrIr
�ipv6Skip�ipv6SkipReasonrL�rJrErr1s.���
P
�d6��H�n�%�1�&�1rJrc�$�eZdZd�Zd�Zd�Zd�Zy)�IOCPReactorTestsc�x�t�}|j�|j|jd��y)zd
        Test reactor behavior (doIteration) when there are no pending time
        events.
        N)r�wakeUp�assertFalse�doIteration)r;�irs  rE�test_noPendingTimerEventsz*IOCPReactorTests.test_noPendingTimerEvents�s+��
�]��
�	�	���������-�.rJc��|jtttj��|jttt
j��y)zY
        Verify that IOCP socket-representing classes implement IReadWriteHandle
        N)�
assertTruerrr�
Connectionr�PortrHs rE�test_reactorInterfacesz'IOCPReactorTests.test_reactorInterfaces�s4��	
����$4�c�n�n�E�F�����$4�c�h�h�?�@rJc�J�|jttt��y)zH
        Verify that L{Filehandle} implements L{IPushProducer}.
        N)r]rrrrHs rE�test_fileHandleInterfacesz*IOCPReactorTests.test_fileHandleInterfaces�s��	
����M�:�>�?rJc��Gd�d�}t�}|�}tj|j|�}t	t
dz�D]#}|jjdt|��%|jd�|j|jt
�|jd�|j|jt
dz�y)z�
        Verify that we don't lose an event when more than EVENTS_PER_LOOP
        events occur in the same reactor iteration
        c��eZdZdZd�Zd�Zy)�;IOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFDrc��y)N�FakeFDrSrHs rE�	logPrefixzEIOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFD.logPrefix�s��rJc�.�|xjdz
c_y)Nr)�counter)r;�rc�bytes�evts    rE�cbz>IOCPReactorTests.test_maxEventsPerIteration.<locals>.FakeFD.cb�s������!�rJN)rMrNrOrjrhrnrSrJrErgre�s���G�
 �
"rJrgrrN)rr0�Eventrnr4rr>�	postEventrrYr/rj)r;rgrZ�fd�event�_s      rE�test_maxEventsPerIterationz+IOCPReactorTests.test_maxEventsPerIteration�s���	"�	"��]��
�X�����B�E�E�2�&�����*�+�	4�A��G�G���a��U�3�	4�
���t��������_�5�
���q��������_�q�%8�9rJN)rMrNrOr[r`rbrtrSrJrErUrU�s��/�A�@�:rJrU)0rPr,�sysr7rrrrrr�structr	�unittestr
�zope.interface.verifyr�twisted.internet.interfacesr�twisted.python.logr
�twisted.trial.unittestr�twisted.internet.iocpreactorrr0rr�%twisted.internet.iocpreactor.abstractr�"twisted.internet.iocpreactor.constr�'twisted.internet.iocpreactor.interfacesr�$twisted.internet.iocpreactor.reactorrrr�ImportError�platform�skipr$rQrRr*r@�strrrUrSrJrE�<module>r�s����
�
���E�E���-�5�"�+�3�K�K�@�K�H����
�8�[�!�'�'�)��H��N�r1�8�r1�j.:�x�.:��M�3�
�|�|�w��
�2�D�	3�����H���V�N���s*�&B!�/B>�!B;�:B;�>C�
C�C

Zerion Mini Shell 1.0