403Webshell
Server IP : 178.105.222.151  /  Your IP : 216.73.216.38
Web Server : nginx/1.28.3
System : Linux MNK 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Wed Apr 22 16:06:43 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.5.4
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/twisted/internet/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/twisted/internet/__pycache__/testing.cpython-314.pyc
+
DfjJ��	�~�Rt^RIHt^RIt^RIHt^RIHt^RIH	t	H
t
^RIHt^RIHtH
t
HtHtHtHtHtHtHt^RIHtHt^R	IHt^R
IHtHt^RIHtHtHtH t ^RI!H"t"H#t#^R
I$H%t%H&t&H't'^RI(H)t)H*t*H+t+^RI,H-t-^RI.H/t/H0t0H1t1H2t2H3t3H4t4H5t5H6t6H7t7H8t8H9t9H:t:H;t;H<t<H=t=H>t>H?t?^RI@HAtA^RIBHCtCHDtDHEtE^RIFHGtG^RIHHItI^RIJHKtK.R>OtL]!R#4tM!R$R%]P�4tO!R&R]P�4tP!R'R]GP�4tR!R(R4tS]!]?]1]64!R)R44tT!R*R]T4tU!R+R]4tV]!]44!R,R44tW]!]04!R-R44tX]!]34]!R.R/444tY]!]24!R0R144tZ]!]7]<];]=]:]8]94!R2R44t[]!][4Ft\]!]\][4K	!R3R][]A4t]]!]<];]=]:]94!R4R 44t^!R5R!4t_R6t`]!]C4!R7R"]]D,44ta]!R84tbR9R:ltcR;R<ltdR=teR#)?zJ
Assorted functionality which is commonly useful when writing unit tests.
)�annotationsN)�	dataclass)�BytesIO)�AF_INET�AF_INET6)�time)	�Any�Callable�	Coroutine�	Generator�Iterator�Sequence�TypeVar�Union�overload)�
implementedBy�implementer)�verifyClass)�	ParamSpec�Self)�address�error�protocol�task)�_dataMustBeBytes�
isIPv6Address)�IPv4Address�IPv6Address�UNIXAddress)�Deferred�ensureDeferred�succeed)�UnsupportedAddressFamily)�IAddress�
IConnector�	IConsumer�IHostnameResolver�IHostResolution�IListeningPort�	IProtocol�
IPushProducer�IReactorCore�
IReactorFDSet�IReactorPluggableNameResolver�IReactorSocket�IReactorSSL�IReactorTCP�IReactorUNIX�IResolutionReceiver�
ITransport)�Clock)�ILogObserver�LogEvent�LogPublisher)�basic)�failure)�TestCase�AccumulatingProtocol�LineSendingProtocol�FakeDatagramTransport�StringTransport� StringTransportWithDisconnection�StringIOWithoutClosing�_FakeConnector�	_FakePort�
MemoryReactor�MemoryReactorClock�RaisingMemoryReactor�NonStreamingProducer�EventLoggingObserver�_Pc�&�]tRt^Rt$RtR]R&RtR#)�_ProtocolConnectionMadeHaverzX
Explicit stipulation of the implicit requirement of L{AccumulatingProtocol}'s factory.
z%Deferred[AccumulatingProtocol] | None�protocolConnectionMade�N)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�__annotations__�__static_attributes__rL��:/usr/lib/python3/dist-packages/twisted/internet/testing.pyrJrJRs���B�ArTrJc��]tRt^Zt$RtR]R&R]R&^;ttRtR]R&Rt	R]R	&R
t
R]R&RtR
]R&RRltRRlt
RRRlltRtR#)r;a8
L{AccumulatingProtocol} is an L{IProtocol} implementation which collects
the data delivered to it and can fire a Deferred when it is connected or
disconnected.

@ivar made: A flag indicating whether C{connectionMade} has been called.
@ivar data: Bytes giving all the data passed to C{dataReceived}.
@ivar closed: A flag indicated whether C{connectionLost} has been called.
@ivar closedReason: The value of the I{reason} parameter passed to
    C{connectionLost}.
@ivar closedDeferred: If set to a L{Deferred}, this will be fired when
    C{connectionLost} is called.
�int�made�closedN�failure.Failure | None�closedReasonzDeferred[None] | None�closedDeferredrT�bytes�datazprotocol.Factory | None�factoryc��V^8�dQhRR/#���return�NonerL)�formats"rU�__annotate__�!AccumulatingProtocol.__annotate__rs�����rTc	��^VnVPpVe7VPe'VPpRVnVPV4R#R#R#��N)rXr_rK�callback)�selfr_�ds&  rU�connectionMade�#AccumulatingProtocol.connectionMadersP����	��L�L�	���7�#A�#A�#M��.�.�A�-1�G�*�
�J�J�t��$N�rTc� �V^8�dQhRRRR/#)rbr^r]rcrdrL)res"rUrfrg|s������4�rTc	�8�V;PV,
unR#�N)r^�rlr^s&&rU�dataReceived�!AccumulatingProtocol.dataReceived|s���	�	�T��	rTc� �V^8�dQhRRRR/#)rb�reasonrZrcrdrL)res"rUrfrgs����%;��t�rTc	��^VnWnVPe'VPRuq nVPR4R#R#ri)rYr[r\rk)rlrwrms&& rU�connectionLost�#AccumulatingProtocol.connectionLosts?�����"�����*�%)�%8�%8�$�"�A�"�
�J�J�t��+rT)rYr\r[rXrr)rMrNrOrPrQrRrXrYr[r\r^r_rnrtryrSrLrTrUr;r;Zs\����I��K���D�6�+/�L�(�/�,0�N�)�0��D�%��'+�G�
$�+����rTc�6�]tRt^�tRtRRltRtRtRtRt	R#)	r<Fc	�<�VR,Vn.VnW nR#):NNNN)�lines�response�start)rlr}rs&&&rU�__init__�LineSendingProtocol.__init__�s���1�X��
���
��
rTc	�v�VP'd'VPFpVPV4K	R#R#rr)rr}�sendLine�rl�lines& rUrn�"LineSendingProtocol.connectionMade�s*���:�:�:��
�
���
�
�d�#�#�rTc	��VP'g,VPFpVPV4K	.VnVPP	V4R#rr)rr}r�r~�appendr�s&&rU�lineReceived� LineSendingProtocol.lineReceived�s>���z�z�z��
�
���
�
�d�#�#��D�J��
�
���T�"rTc	��RVnR#�TN)�lostConn)rlrws&&rUry�"LineSendingProtocol.connectionLost�s	����
rT)r}r�r~rN)T)
rMrNrOrPr�r�rnr�ryrSrLrTrUr<r<�s���H��
$�
#�rTc�6�]tRt^�t]!4tRt]3RltRtR#)r=c	��.VnR#rr��written�rls&rUr��FakeDatagramTransport.__init__�s	����rTc	�>�VPPW34R#rr)r�r�)rl�packet�addrs&&&rU�write�FakeDatagramTransport.write�s�������V�N�+rTr�N)	rMrNrOrP�object�noAddrr�r�rSrLrTrUr=r=�s��
�X�F��"(�,�,rTc��]tRt^�tRtRtRtRtRtRt	Rt
RtRRltRt
RtRtR	tR
tRtRtR
tRtRtRtRtRtRtRtR#)r>a&
A transport implementation which buffers data in memory and keeps track of
its other state without providing any behavior.

L{StringTransport} has a number of attributes which are not part of any of
the interfaces it claims to implement.  These attributes are provided for
testing purposes.  Implementation code should not use any of these
attributes; they are not provided by other transports.

@ivar disconnecting: A C{bool} which is C{False} until L{loseConnection} is
    called, then C{True}.

@ivar disconnected: A C{bool} which is C{False} until L{abortConnection} is
    called, then C{True}.

@ivar producer: If a producer is currently registered, C{producer} is a
    reference to it.  Otherwise, L{None}.

@ivar streaming: If a producer is currently registered, C{streaming} refers
    to the value of the second parameter passed to C{registerProducer}.

@ivar hostAddr: L{None} or an object which will be returned as the host
    address of this transport.  If L{None}, a nasty tuple will be returned
    instead.

@ivar peerAddr: L{None} or an object which will be returned as the peer
    address of this transport.  If L{None}, a nasty tuple will be returned
    instead.

@ivar producerState: The state of this L{StringTransport} in its capacity
    as an L{IPushProducer}.  One of C{'producing'}, C{'paused'}, or
    C{'stopped'}.

@ivar io: A L{io.BytesIO} which holds the data which has been written to
    this transport since the last call to L{clear}.  Use L{value} instead
    of accessing this directly.

@ivar _lenient: By default L{StringTransport} enforces that
    L{resumeProducing} is not called after the connection is lost. This is
    to ensure that any code that does call L{resumeProducing} after the
    connection is lost is not blindly expecting L{resumeProducing} to have
    any impact.

    However, if your test case is calling L{resumeProducing} after
    connection close on purpose, and you know it won't block expecting
    further data to show up, this flag may safely be set to L{True}.

    Defaults to L{False}.
@type lenient: L{bool}
FN�	producingc	�h�VP4VeWnVeW nRVnW0nR#)NT)�clear�hostAddr�peerAddr�	connected�_lenient)rl�hostAddress�peerAddress�lenients&&&&rUr��StringTransport.__init__�s-���
�
���"�'�M��"�'�M�����
rTc
�$�\4VnR#)z�
Discard all data written to this transport so far.

This is not a transport method.  It is intended for tests.  Do not use
it in implementation code.
N)r�ior�s&rUr��StringTransport.clear�s
���)��rTc
�6�VPP4#)a
Retrieve all data which has been buffered by this transport.

This is not a transport method.  It is intended for tests.  Do not use
it in implementation code.

@return: A C{bytes} giving all data written to this transport since the
    last call to L{clear}.
@rtype: C{bytes}
)r��getvaluer�s&rU�value�StringTransport.value�s���w�w���!�!rTc	�R�\V4VPPV4R#rr)rr�r�rss&&rUr��StringTransport.write	s��������
�
�d�rTc	�Z�VPPRPV44R#)rTN)r�r��joinrss&&rU�
writeSequence�StringTransport.writeSequence
s�����
�
�c�h�h�t�n�%rTc
��RVnR#)zf
Close the connection. Does nothing besides toggle the C{disconnecting}
instance variable to C{True}.
TN)�
disconnectingr�s&rU�loseConnection�StringTransport.loseConnections��
"��rTc
�4�RVnVP4R#)zp
Abort the connection. Same as C{loseConnection}, but also toggles the
C{aborted} instance variable to C{True}.
TN)�disconnectedr�r�s&rU�abortConnection�StringTransport.abortConnections��
!������rTc	�f�VPf\P!RRR4#VP#)N�TCPz192.168.1.1i1�)r�rrr�s&rU�getPeer�StringTransport.getPeers+���=�=� ��&�&�u�m�U�C�C��}�}�rTc	�f�VPf\P!RRR4#VP#)Nr�z10.0.0.1i90)r�rrr�s&rU�getHost�StringTransport.getHost$s+���=�=� ��&�&�u�j�%�@�@��}�}�rTc	�P�VPe\R4hWnW nR#)NzCannot register two producers��producer�RuntimeError�	streaming)rlr�r�s&&&rU�registerProducer� StringTransport.registerProducer*s"���=�=�$��>�?�?� �
�"�rTc	�T�VPf\R4hRVnRVnR#)Nz5Cannot unregister a producer unless one is registeredr�r�s&rU�unregisterProducer�"StringTransport.unregisterProducer0s&���=�=� ��V�W�W���
���rTc	��VP'dVP'g\R4hVPR8Xd\R4hR#)z,Cannot resume producing after loseConnection�stoppedz Cannot resume a stopped producerN)r�r�r��
producerStater�s&rU�_checkState�StringTransport._checkState7sA������d�m�m�m��M�N�N�����*��A�B�B�+rTc	�4�VP4RVnR#)�pausedN�r�r�r�s&rU�pauseProducing�StringTransport.pauseProducing=s������%��rTc	��RVnR#)r�N)r�r�s&rU�
stopProducing�StringTransport.stopProducingAs
��&��rTc	�4�VP4RVnR#)r�Nr�r�s&rU�resumeProducing�StringTransport.resumeProducingDs������(��rT)
r�r�r�r�r�r�r�r�r�r�)NNF)rMrNrOrPrQr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rSrLrTrUr>r>�sy��1�f�M��L��H��I��H��H��M� ��"��&�"���
�#��C�&�'�)rTc�,�]tRtRt$RtR]R&RtRtR#)r?iIzh
A L{StringTransport} which on disconnection will trigger the connection
lost on the attached protocol.
r)rc	���VP'dMRVnVPP\P!\
P!R444R#R#)FzBye.N)r�rryr9�Failurer�ConnectionDoner�s&rUr��/StringTransportWithDisconnection.loseConnectionQs=���>�>�>�"�D�N��M�M�(�(�����9M�9M�f�9U�)V�W�rT)r�N)rMrNrOrPrQrRr�rSrLrTrUr?r?Is���
��XrTc� �]tRtRtRtRtRtR#)r@iWz!
A BytesIO that can't be closed.
c
��R#)z
Do nothing.
NrLr�s&rU�close�StringIOWithoutClosing.close\��rTrLN)rMrNrOrPrQr�rSrLrTrUr@r@Ws���rTc�2�]tRtRtRtRtRtRtRtRt	R#)	rBibz�
A fake L{IListeningPort} to be used in tests.

@ivar _hostAddress: The L{IAddress} this L{IListeningPort} is pretending
    to be listening on.
c
��WnR#)zb
@param hostAddress: An L{IAddress} this L{IListeningPort} should
    pretend to be listening on.
N��_hostAddress)rlr�s&&rUr��_FakePort.__init__ks
��
(�rTc
��R#)zA
Fake L{IListeningPort.startListening} that doesn't do anything.
NrLr�s&rU�startListening�_FakePort.startListeningrr�rTc
��R#)z@
Fake L{IListeningPort.stopListening} that doesn't do anything.
NrLr�s&rU�
stopListening�_FakePort.stopListeningwr�rTc
��VP#)z>
Fake L{IListeningPort.getHost} that returns our L{IAddress}.
r�r�s&rUr��_FakePort.getHost|s��� � � rTr�N)
rMrNrOrPrQr�r�r�r�rSrLrTrUrBrBbs���(��
�
!rTc�@�]tRtRtRtRtRtRtRtRt	Rt
RtR	tR
#)rAi�a
A fake L{IConnector} that allows us to inspect if it has been told to stop
connecting.

@ivar stoppedConnecting: has this connector's
    L{_FakeConnector.stopConnecting} method been invoked yet?

@ivar _address: An L{IAddress} provider that represents our destination.
Fc
��WnR#)z[
@param address: An L{IAddress} provider that represents this
    connector's destination.
N��_address)rlrs&&rUr��_FakeConnector.__init__�s	��
 �
rTc
��RVnR#)z_
Implement L{IConnector.stopConnecting} and set
L{_FakeConnector.stoppedConnecting} to C{True}
TN)�stoppedConnectingr�s&rU�stopConnecting�_FakeConnector.stopConnecting�s��
"&��rTc
��RVnR#)z0
Implement L{IConnector.disconnect} as a no-op.
TN)�
_disconnectedr�s&rU�
disconnect�_FakeConnector.disconnect�s��"��rTc
��R#)z-
Implement L{IConnector.connect} as a no-op.
NrLr�s&rU�connect�_FakeConnector.connect�r�rTc
��VP#)zX
Implement L{IConnector.getDestination} to return the C{address} passed
to C{__init__}.
r�r�s&rU�getDestination�_FakeConnector.getDestination�s��
�}�}�rT)r�r�r�N)
rMrNrOrPrQr�r�r�r�rrrrSrLrTrUrArA�s-����M��� �&�"��
rTc�.�]tRtRt$R]R&RRltRtR#)�_SynchronousResolutioni��str�namec��V^8�dQhRR/#rarL)res"rUrf�#_SynchronousResolution.__annotate__�s��,�,��,rTc
��\R4h)zs
Provided just for interface compliance; it should be impossible to
reach here, since it's resolved synchronously.
zalready resolved)�	Exceptionr�s&rU�cancel�_SynchronousResolution.cancel�s��
�*�+�+rTrLN)rMrNrOrPrRrrSrLrTrUr	r	�s���I�,�,rTr	c�*�]tRtRtRtRRRlltRtR#)�SynchronousResolveri�z�
A very simple L{IHostnameResolver} that immediately, synchronously resolves
all host names to a single static address (TCPv4, 127.0.0.1) while
preserving any requested port number.
Nc�0�V^8�dQhRRRRRRRRR	RR
R/#)rb�resolutionReceiverr2�hostNamer
�
portNumberrW�addressTypeszSequence[type[IAddress]] | None�transportSemanticsrcr'rL)res"rUrf� SynchronousResolver.__annotate__�sF����/�����	�
6�� �
�
�rTc
��\V4pVPV4VP\RRV44VP	4V#)z|
Implement L{IHostnameResolver.resolveHostName} to synchronously resolve
the name and complete resolution before returning.
r�z	127.0.0.1)r	�resolutionBegan�addressResolvedr�resolutionComplete)rlrrrrr�
resolutions&&&&&& rU�resolveHostName�#SynchronousResolver.resolveHostName�sE��,�H�5�
��*�*�:�6��*�*�;�u�k�:�+V�W��-�-�/��rTrL)�Nr�)rMrNrOrPrQr rSrLrTrUrr�s����rTrc��]tRtRt$RtR]R&RtRRltRtR&R	lt	R
t
RtRtR'R
lt
RtRRltRtRRltRtRtR(RltR)RltR*RltR)RltR*RltR+RltR,RltRtRtR tR!tR"tR#t R$t!R%t"R#)-rCi�a�
A fake reactor to be used in tests.  This reactor doesn't actually do
much that's useful yet.  It accepts TCP connection setup attempts, but
they will never succeed.

@ivar hasInstalled: Keeps track of whether this reactor has been installed.
@type hasInstalled: L{bool}

@ivar running: Keeps track of whether this reactor is running.
@type running: L{bool}

@ivar hasStopped: Keeps track of whether this reactor has been stopped.
@type hasStopped: L{bool}

@ivar hasCrashed: Keeps track of whether this reactor has crashed.
@type hasCrashed: L{bool}

@ivar whenRunningHooks: Keeps track of hooks registered with
    C{callWhenRunning}.
@type whenRunningHooks: L{list}

@ivar triggers: Keeps track of hooks registered with
    C{addSystemEventTrigger}.
@type triggers: L{dict}

@ivar tcpClients: Keeps track of connection attempts (ie, calls to
    C{connectTCP}).
@type tcpClients: L{list}

@ivar tcpServers: Keeps track of server listen attempts (ie, calls to
    C{listenTCP}).
@type tcpServers: L{list}

@ivar sslClients: Keeps track of connection attempts (ie, calls to
    C{connectSSL}).
@type sslClients: L{list}

@ivar sslServers: Keeps track of server listen attempts (ie, calls to
    C{listenSSL}).
@type sslServers: L{list}

@ivar unixClients: Keeps track of connection attempts (ie, calls to
    C{connectUNIX}).
@type unixClients: L{list}

@ivar unixServers: Keeps track of server listen attempts (ie, calls to
    C{listenUNIX}).
@type unixServers: L{list}

@ivar adoptedPorts: Keeps track of server listen attempts (ie, calls to
    C{adoptStreamPort}).

@ivar adoptedStreamConnections: Keeps track of stream-oriented
    connections added using C{adoptStreamConnection}.
r&�nameResolverc
�@�RVnRVnRVnRVnRVn.Vn/Vn.Vn.Vn.Vn	.Vn
.Vn.Vn.Vn
.Vn.Vn\!4Vn\!4Vn\'4VnR#)z 
Initialize the tracking lists.
FTN)�hasInstalled�running�hasRun�
hasStopped�
hasCrashed�whenRunningHooks�triggers�
tcpClients�
tcpServers�
sslClients�
sslServers�unixClients�unixServers�adoptedPorts�adoptedStreamConnections�
connectors�set�readers�writersrr$r�s&rUr��MemoryReactor.__init__s���"��������������� "�����
����������������������(*��%�����u����u���/�1��rTc� �V^8�dQhRRRR/#)rb�resolverr&rcrL)res"rUrf�MemoryReactor.__annotate__;s����,=��BS�rTc
�*�VPpWnV#�z-
Implement L{IReactorPluggableNameResolver}.
�r$)rlr;�oldResolvers&& rU�installNameResolver�!MemoryReactor.installNameResolver;s���'�'��$���rTc
��RVnR#)z?
Fake install callable to emulate reactor module installation.
TN)r&r�s&rU�install�MemoryReactor.installCs��!��rTc
��\4h�z1
Not implemented; raises L{NotImplementedError}.
��NotImplementedError)rlr�timeouts&&&rU�resolve�MemoryReactor.resolveI�
��"�#�#rTc
��VPRJgQhRVnRVnVPFwrpV!V/VBK	VP4R#)z�
Fake L{IReactorCore.run}.
Sets C{self.running} to L{True}, runs all of the hooks passed to
C{self.callWhenRunning}, then calls C{self.stop} to simulate a request
to stop the reactor.
Sets C{self.hasRun} to L{True}.
FTN)r'r(r+�stop)rl�f�args�kwargss&   rU�run�MemoryReactor.runOsP���|�|�u�$�$�$�������#�4�4�O�A�V�
�t��v�� 5�	
�	�	�rTc
�"�RVnRVnR#)za
Fake L{IReactorCore.run}.
Sets C{self.running} to L{False}.
Sets C{self.hasStopped} to L{True}.
FTN)r'r)r�s&rUrO�MemoryReactor.stopas�������rTc
�"�RVnRVnR#)z}
Fake L{IReactorCore.crash}.
Sets C{self.running} to L{None}, because that feels crashy.
Sets C{self.hasCrashed} to L{True}.
NT)r'r*r�s&rU�crash�MemoryReactor.crashjs�������rTc
��\4hrGrH)rl�delays&&rU�iterate�MemoryReactor.iteratesrMrTc
��\4hrGrH)rl�	eventTypes&&rU�fireSystemEvent�MemoryReactor.fireSystemEventyrMrTc�0�V^8�dQhRRRRRRRRRR	R
R/#)rb�phaser
r_�callable�Callable[_P, object]rQ�_P.args�kw�	_P.kwargsrcrdrL)res"rUrfr<sF��7�7��7��7�'�	7�
�7��
7�
�7rTc
��VPPV/4pVPV.4pVPW4V34R#)ze
Fake L{IReactorCore.run}.
Keep track of trigger by appending it to
self.triggers[phase][eventType].
N)r,�
setdefaultr�)rlrcr_rdrQrg�
phaseTriggers�eventTypeTriggerss&&&&*,  rU�addSystemEventTrigger�#MemoryReactor.addSystemEventTriggers@���
�
�0�0���;�
�)�4�4�Y��C��� � �(�"�!5�6rTc
��\4hrGrH)rl�	triggerIDs&&rU�removeSystemEventTrigger�&MemoryReactor.removeSystemEventTrigger�rMrTc�(�V^8�dQhRRRRRRRR/#)	rbrdrerQrfrgrhrcrdrL)res"rUrfr<�s,��;�;�,�;�5<�;�DM�;�	
�;rTc
�@�VPPWV34R#)zh
Fake L{IReactorCore.callWhenRunning}.
Keeps a list of invocations to make in C{self.whenRunningHooks}.
N)r+r�)rlrdrQrgs&&*,rU�callWhenRunning�MemoryReactor.callWhenRunning�s��	
���$�$�h�b�%9�:rTc
���V\8Xd\RRR4pM#V\8Xd\RRR4pM
\	4hVP
P
WV34\V4#)z^
Fake L{IReactorSocket.adoptStreamPort}, that logs the call and returns
an L{IListeningPort}.
r��0.0.0.0���::�rrrrr"r3r�rB)rl�fileno�
addressFamilyr_r�s&&&& rU�adoptStreamPort�MemoryReactor.adoptStreamPort�s\��
�G�#��u�i��6�D�
�h�
&��u�d�D�1�D�*�,�,���� � �&��!A�B����rTc
�@�VPPWV34R#)z�
Record the given stream connection in C{adoptedStreamConnections}.

@see:
    L{twisted.internet.interfaces.IReactorSocket.adoptStreamConnection}
N)r4r��rl�fileDescriptorr}r_s&&&&rU�adoptStreamConnection�#MemoryReactor.adoptStreamConnection�s��	
�%�%�,�,�n�W�-U�VrTc
���V\8Xd\RRR4pM#V\8Xd\RRR4pM
\	4hVP
P
WW434\V4#)z�
Fake L{IReactorSocket.adoptDatagramPort}, that logs the call and
returns a fake L{IListeningPort}.

@see: L{twisted.internet.interfaces.IReactorSocket.adoptDatagramPort}
�UDPrxryrzr{)rlr|r}r�
maxPacketSizer�s&&&&& rU�adoptDatagramPort�MemoryReactor.adoptDatagramPort�s\���G�#��u�i��6�D�
�h�
&��u�d�D�1�D�*�,�,���� � �&��!Q�R����rTc
��VPPWW434\V4'd\RWA4pM
\	RRV4p\V4#)zU
Fake L{IReactorTCP.listenTCP}, that logs the call and
returns an L{IListeningPort}.
r�rx)r.r�rrrrB)rl�portr_�backlog�	interfacers&&&&& rU�	listenTCP�MemoryReactor.listenTCP�sK��
	
������w�B�C���#�#�!�%��9�G�!�%��D�9�G���!�!rTNc
��VPPWW4V34\V4'd\\	RW44pM\\RW44pVP
V4VPPV4V#)zR
Fake L{IReactorTCP.connectTCP}, that logs the call and
returns an L{IConnector}.
r�)r-r�rrArr�startedConnectingr5)rl�hostr�r_rJ�bindAddress�conns&&&&&& rU�
connectTCP�MemoryReactor.connectTCP�so��
	
������G�k�J�K�����!�+�e�T�"@�A�D�!�+�e�T�"@�A�D��!�!�$�'������t�$��rTc
�j�VPPWW4V34\\RRV44#)zU
Fake L{IReactorSSL.listenSSL}, that logs the call and
returns an L{IListeningPort}.
r�rx)r0r�rBr�rlr�r_�contextFactoryr�r�s&&&&&&rU�	listenSSL�MemoryReactor.listenSSL�s1��
	
������~�	�R�S���U�I�t�<�=�=rTc
���VPPWW4WV34\\RW44pVP	V4VP
PV4V#)zR
Fake L{IReactorSSL.connectSSL}, that logs the call and returns an
L{IConnector}.
r�)r/r�rArr�r5)rlr�r�r_r�rJr�r�s&&&&&&& rU�
connectSSL�MemoryReactor.connectSSL�sX��	
�����
��'�G�	
��k�%��<�=���!�!�$�'������t�$��rTc
�f�VPPWW4V34\\V44#)zW
Fake L{IReactorUNIX.listenUNIX}, that logs the call and returns an
L{IListeningPort}.
)r2r�rBr�rlrr_r��mode�wantPIDs&&&&&&rU�
listenUNIX�MemoryReactor.listenUNIX�s/��
	
������7�'� J�K���W�-�.�.rTc
��VPPWW434\\V44pVP	V4VP
PV4V#)zT
Fake L{IReactorUNIX.connectUNIX}, that logs the call and returns an
L{IConnector}.
)r1r�rArr�r5)rlrr_rJ�checkPIDr�s&&&&& rU�connectUNIX�MemoryReactor.connectUNIXsQ��
	
������7� E�F��k�'�2�3���!�!�$�'������t�$��rTc
�<�VPPV4R#)zG
Fake L{IReactorFDSet.addReader} which adds the reader to a local set.
N)r7�add�rl�readers&&rU�	addReader�MemoryReactor.addReader���	
������ rTc
�<�VPPV4R#)zO
Fake L{IReactorFDSet.removeReader} which removes the reader from a
local set.
N)r7�discardr�s&&rU�removeReader�MemoryReactor.removeReader���
	
�����V�$rTc
�<�VPPV4R#)zG
Fake L{IReactorFDSet.addWriter} which adds the writer to a local set.
N)r8r��rl�writers&&rU�	addWriter�MemoryReactor.addWriterr�rTc
�<�VPPV4R#)zO
Fake L{IReactorFDSet.removeWriter} which removes the writer from a
local set.
N)r8r�r�s&&rU�removeWriter�MemoryReactor.removeWriterr�rTc
�,�\VP4#)zV
Fake L{IReactorFDSet.getReaders} which returns a list of readers from
the local set.
)�listr7r�s&rU�
getReaders�MemoryReactor.getReaders&���
�D�L�L�!�!rTc
�,�\VP4#)zV
Fake L{IReactorFDSet.getWriters} which returns a list of writers from
the local set.
)r�r8r�s&rU�
getWriters�MemoryReactor.getWriters-r�rTc
�n�VPP4VPP4R#)z\
Fake L{IReactorFDSet.removeAll} which removed all readers and writers
from the local sets.
N)r7r�r8r�s&rU�	removeAll�MemoryReactor.removeAll4s$��
	
�����������rT)r3r4r5r*r&r(r)r$r7r'r/r0r-r.r,r1r2r+r8)�
�r")i ��2���N�r�i�r"�r�r")#rMrNrOrPrQrRr�rArDrKrSrOrXr\r`rmrqrur~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rSrLrTrUrCrC�s���6�p$�#�2�8�!�$��$��$�$�7�"$�;�
�W��"
"��>�
�/�	�!�%�!�%�"�"�rTc��]tRtRtRtRtR#)rDiAc	�\�\PV4\P!V4R#rr)rCr�r4r�s&rUr��MemoryReactorClock.__init__Bs�����t�$�
���t�rTrLN)rMrNrOrPr�rSrLrTrUrDrDAs��rTc��]tRtRtRtRRRlltRRltRtRR	ltRR
lt	RRlt
RRltRR
ltRRlt
RtRtRtR#)rEiGz�
A fake reactor to be used in tests.  It accepts TCP connection setup
attempts, but they will fail.

@ivar _listenException: An instance of an L{Exception}
@ivar _connectException: An instance of an L{Exception}
Nc�$�V^8�dQhRRRRRR/#)rb�listenExceptionzException | None�connectExceptionrcrdrL)res"rUrf�!RaisingMemoryReactor.__annotate__Ws-��E�E�)�E�+�E�
�	ErTc
�<�WnW n\4VnR#)z�
@param listenException: An instance of an L{Exception} to raise
    when any C{listen} method is called.

@param connectException: An instance of an L{Exception} to raise
    when any C{connect} method is called.
N)�_listenException�_connectExceptionrr$)rlr�r�s&&&rUr��RaisingMemoryReactor.__init__Ws��!0��!1��/B�/D��rTc� �V^8�dQhRRRR/#)rbr$r&rcrL)res"rUrfr�gs����0A��FW�rTc
�,�VPVuq nV#r>r?)rlr$�previouss&& rUrA�(RaisingMemoryReactor.installNameResolvergs��'+�&7�&7��#��#��rTc
��VPh)zJ
Fake L{IReactorSocket.adoptStreamPort}, that raises
L{_listenException}.
�r�)rlr|r}r_s&&&&rUr~�$RaisingMemoryReactor.adoptStreamPortns��
�#�#�#rTc
��VPh)zA
Fake L{IReactorTCP.listenTCP}, that raises L{_listenException}.
r�)rlr�r_r�r�s&&&&&rUr��RaisingMemoryReactor.listenTCPu����#�#�#rTc
��VPh)zC
Fake L{IReactorTCP.connectTCP}, that raises L{_connectException}.
�r�)rlr�r�r_rJr�s&&&&&&rUr��RaisingMemoryReactor.connectTCP{����$�$�$rTc
��VPh)zA
Fake L{IReactorSSL.listenSSL}, that raises L{_listenException}.
r�r�s&&&&&&rUr��RaisingMemoryReactor.listenSSL�r�rTc
��VPh)zC
Fake L{IReactorSSL.connectSSL}, that raises L{_connectException}.
r�)rlr�r�r_r�rJr�s&&&&&&&rUr��RaisingMemoryReactor.connectSSL�s���$�$�$rTc
��VPh)zC
Fake L{IReactorUNIX.listenUNIX}, that raises L{_listenException}.
r�r�s&&&&&&rUr��RaisingMemoryReactor.listenUNIX�r�rTc
��VPh)zE
Fake L{IReactorUNIX.connectUNIX}, that raises L{_connectException}.
r�)rlrr_rJr�s&&&&&rUr�� RaisingMemoryReactor.connectUNIX�r�rTc
��VPh)zM
Fake L{IReactorSocket.adoptDatagramPort}, that raises
L{_connectException}.
r�)rlr�r}rr�s&&&&&rUr��&RaisingMemoryReactor.adoptDatagramPort����
�$�$�$rTc
��VPh)zQ
Fake L{IReactorSocket.adoptStreamConnection}, that raises
L{_connectException}.
r�r�s&&&&rUr��*RaisingMemoryReactor.adoptStreamConnection�r�rT)r�r�r$)NNr�r�r�r�)rMrNrOrPrQr�rAr~r�r�r�r�r�r�r�r�rSrLrTrUrErEGs?���E� �$�$�%�$�%�$�%�%�%rTc�@�]tRtRtRt^tRtRtRtRt	Rt
RtR	tR
#)rFi�z-
A pull producer which writes 10 times only.
Fc	�0�Wn\4VnR#rr)�consumerr�result)rlr�s&&rUr��NonStreamingProducer.__init__�s�� �
��j��rTc
�`�VPeVP^
8�d\R4hVPPRVP3,4V;P^,
unVP^
8Xd-VPP	4VP4R#R#)z
Write the counter value once.
Nz"BUG: resume after unregister/stop.s%d)r��counterr�r�r��_doner�s&rUr��$NonStreamingProducer.resumeProducing�sz���=�=� �D�L�L�B�$6��C�D�D��M�M�������� 7�8��L�L�A��L��|�|�r�!��
�
�0�0�2��
�
��"rTc
��\R4h)z�
An implementation of C{IPushProducer.pauseProducing}. This should never
be called on a pull producer, so this just raises an error.
z"BUG: pause should never be called.)r�r�s&rUr��#NonStreamingProducer.pauseProducing�s��
�?�@�@rTc
�R�RVnVPpV=VPR4R#)zA
Fire a L{Deferred} so that users can wait for this to complete.
N)r�r�rk)rlrms& rUr��NonStreamingProducer._done�s%����
��K�K���K�	�
�
�4�rTc
�4�RVnVP4R#)z
Stop all production.
TN)r�r�r�s&rUr��"NonStreamingProducer.stopProducing�s������
�
�rT)r�r�r�N)
rMrNrOrPrQr�r�r�r�r�r�r�rSrLrTrUrFrF�s-����G��G�!��A��rTc�xaa�RoVV3Rlp\P!V4oVSnSPRRR7#)a�
Take a list of disconnecting protocols, callback a L{Deferred} when they're
all done.

This is a hack to make some older tests less flaky, as
L{ITransport.loseConnection} is not atomic on all reactors (for example,
the CoreFoundation, which sometimes takes a reactor turn for CFSocket to
realise). New tests should either not use real sockets in testing, or take
the advice in
I{https://jml.io/pages/how-to-disconnect-in-twisted-really.html} to heart.

@param reactor: The reactor to schedule the checks on.
@type reactor: L{IReactorTime}

@param protocols: The protocols to wait for disconnecting.
@type protocols: A L{list} of L{IProtocol}s.
Nc�<�RSUu.uFqPPNK	up9dSP4R#R#uupir�)�	transportr�rO)�x�lc�	protocolss ��rU�_check�(waitUntilAllDisconnected.<locals>._check�s4����y�A�y�!���-�-�y�A�A��G�G�I�B��As�Ag{�G�z�?T)�now)r�LoopingCall�clockr)�reactorrr
rs&f @rU�waitUntilAllDisconnectedr�s;���$
�B��
�	�	�&�	!�B��B�H�
�8�8�D�d�8�#�#rTc��]tRtRtRtRRltRRlt]RRl4t]R	R
l4tRRltR
Rlt	RRlt
]RRl4tRt
R#)rGi�ah
L{ILogObserver} That stores its events in a list for later inspection.
This class is similar to L{LimitedHistoryLogObserver} save that the
internal buffer is public and intended for external inspection.  The
observer implements the sequence protocol to ease iteration of the events.

@ivar _events: The events captured by this observer
@type _events: L{list}
c��V^8�dQhRR/#rarL)res"rUrf�!EventLoggingObserver.__annotate__s��*�*�$�*rTc	��.VnR#rr��_eventsr�s&rUr��EventLoggingObserver.__init__s	��')��rTc��V^8�dQhRR/#)rbrcrWrL)res"rUrfrs��!�!��!rTc	�,�\VP4#rr)�lenrr�s&rU�__len__�EventLoggingObserver.__len__s���4�<�<� � rTc� �V^8�dQhRRRR/#)rb�indexrWrcr6rL)res"rUrfrs�������rTc	��R#rrrL�rlr!s&&rU�__getitem__� EventLoggingObserver.__getitem__
���rTc� �V^8�dQhRRRR/#)rbr!�slicerczSequence[LogEvent]rL)res"rUrfrs������+=�rTc	��R#rrrLr#s&&rUr$r%r&rTc� �V^8�dQhRRRR/#)rbr!zint | slicerczLogEvent | Sequence[LogEvent]rL)res"rUrfrs��#�#��#�1N�#rTc	�(�VPV,#rrrr#s&&rUr$r%s���|�|�E�"�"rTc��V^8�dQhRR/#)rbrczIterator[LogEvent]rL)res"rUrfrs��"�"�,�"rTc	�,�\VP4#rr)�iterrr�s&rU�__iter__�EventLoggingObserver.__iter__s���D�L�L�!�!rTc� �V^8�dQhRRRR/#)rb�eventr6rcrdrL)res"rUrfrs��#�#�h�#�4�#rTc
�<�VPPV4R#)z
@see: L{ILogObserver}
N)rr�)rlr2s&&rU�__call__�EventLoggingObserver.__call__s��	
�����E�"rTc�$�V^8�dQhRRRRRR/#)rb�testInstancer:�	publisherr7rcrrL)res"rUrfrs"����X��,��SW�rTc
�faa�V!4oSPS4VPVV3Rl4S#)a�
Create an L{EventLoggingObserver} instance that observes the provided
publisher and will be cleaned up with addCleanup().

@param testInstance: Test instance in which this logger is used.
@type testInstance: L{twisted.trial.unittest.TestCase}

@param publisher: Log publisher to observe.
@type publisher: twisted.logger.LogPublisher

@return: An EventLoggingObserver configured to observe the provided
    publisher.
@rtype: L{twisted.test.proto_helpers.EventLoggingObserver}
c�&<�SPS4#rr)�removeObserver)�obsr8s��rU�<lambda>�8EventLoggingObserver.createWithCleanup.<locals>.<lambda>0s���	�(@�(@��(ErT)�addObserver�
addCleanup)�clsr7r8r<s&&f@rU�createWithCleanup�&EventLoggingObserver.createWithCleanups.��� �e�����c�"���� E�F��
rTrN)rMrNrOrPrQr�rrr$r/r4�classmethodrBrSrLrTrUrGrG�s\���*�!���������#�"�#����rT�_Tc� �V^8�dQhRRRR/#)rb�test_targetzgCallable[[], Union[Coroutine[Deferred[Any], Any, _T], Generator[Deferred[Any], Any, _T], Deferred[_T]]]rczCallable[[Any], None]rL)res"rUrfrf7s ��+�+��+��+rTc�(aa�V3RloRV3RllpV#)z�
Decorator for running a benchmark tests that loops the reactor.

This is designed to decorate test method executed using pytest and
pytest-benchmark.
c�$<�\S!44#rr)r )rGs�rU�deferredWrapper�._benchmarkWithReactor.<locals>.deferredWrapperHs����k�m�,�,rTc� �V^8�dQhRRRR/#)rb�	benchmarkrrcrdrL)res"rUrf�+_benchmarkWithReactor.<locals>.__annotate__Ks��0�0�#�0�$�0rTc��<�\4p\R4\4V,
p\4p\S4\4V,
pW2,^8d\R4hV!\S4R#)c��\R4#rr)r!rLrTrUr=�?_benchmarkWithReactor.<locals>.benchmark_test.<locals>.<lambda>Qs��G�D�MrTz�The function you are benchmarking is fast enough that its run time is being swamped by the startup/shutdown of the reactor. Consider adding a for loop to the benchmark function so it does the work a number of times.N)r�_runReactorr�)rMr�justReactorElapsed�benchmarkElapsedrJs&   �rU�benchmark_test�-_benchmarkWithReactor.<locals>.benchmark_testKsf���
����)�*�!�V�e�^������O�$��6�E�>���0�1�4��B��
�	�+��/rTrL)rGrUrJsf @rU�_benchmarkWithReactorrW7s���"-�0�0�.�rTc� �V^8�dQhRRRR/#)rbrkzCallable[[], Deferred[_T]]rcrdrL)res"rUrfrfes��#�#�4�#��#rTc��a�^RIHo.pV!4pVPVP4VP	V3Rl4SPRR7V'dV^,P
4R#R#)z>
(re)Start a reactor that might have been previously started.
�rc�2<�SP^\S4#r�)�	callLater�_stopReactor)�_rs&�rUr=�_runReactor.<locals>.<lambda>rs���w�0�0��L�'�JrTF)�installSignalHandlersN)�twisted.internetr�
addErrbackr��addBothrS�raiseException)rk�errors�deferredrs&  @rUrRrRes[���)�$&�F��z�H�����
�
�&����J�K��K�K�e�K�,�
��q�	� � �"�rTc�X�VP4VP4\VR4'gQh\VR4'gQh\VR4'gQh\VR4'gQhRVnRVnRVnRVnVPRRVP4R#)	z7
Stop the reactor and allow it to be re-started later.
�_startedBefore�_started�_justStoppedr'F�during�startupN)	rOr\�hasattrrhrirjr'rm�_reallyStartRunningrZs&rUr]r]zs����L�L�N��O�O���7�,�-�-�-�-��7�J�'�'�'�'��7�N�+�+�+�+��7�I�&�&�&�&�"�G���G�� �G���G�O��!�!�(�I�w�7R�7R�SrT)r;r<r=r>r?r@rArBrCrDrErFrrG)frQ�
__future__r�typing�dataclassesrr�r�socketrrrrr	r
rrr
rrr�zope.interfacerr�zope.interface.verifyrrrrarrrr�twisted.internet.abstractrr�twisted.internet.addressrrr�twisted.internet.deferrr r!�twisted.internet.errorr"�twisted.internet.interfacesr#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3�twisted.internet.taskr4�twisted.loggerr5r6r7�twisted.protocolsr8�twisted.pythonr9�twisted.trial.unittestr:�__all__rH�ProtocolrJr;�LineReceiverr<r=r>r?r@rBrAr	rrC�ifacerDrErFrrGrErWrRr]rLrTrU�<module>r�sv��
�#�
�!��$��
�
�
�6�-�"�;�;�E�J�J�D�D�;������&(�?�?�#�"�+���"�t�_��B�6�?�?�B�*�8�,�,�*�Z�%�,�,��0,�,�
�Z��M�2�\)�\)�3�\)�~X��X��W��
�^��!�!��!�@
�Z��,�,��,�^
�_��
�,�,���,�
�
���� ��4
�������!��V�V��V�r
�=�
)�E���}�%�*�����
�����!��Y%�Y%��Y%�x.�.�b$�:
�\��8�8�H�-�8��8�v
�T�]��+�\#�*TrT

Youez - 2016 - github.com/yon3zu
LinuXploit