/usr/lib/python3/dist-packages/twisted/internet/test/__pycache__
Edit: /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/connectionmixins.cpython-310.pyc (24452B)
o
bN @ s d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl
mZmZ ddl
mZmZ dd lmZmZmZ dd
lmZ ddlmZmZ ddlmZ dd
lmZmZmZ ddlm Z ddl!m"Z" ddl#m$Z$ dej%ej&fddZ'G dd deZ(G dd dZ)G dd deZ*dd Z+dd Z,G dd deZ-G d d! d!Z.G d"d# d#eZ/G d$d% d%e(Z0G d&d' d'Z1G d(d) d)Z2G d*d+ d+Z3G d,d- d-Z4dS ).z?
Various helpers for tests for connection-oriented transports.
N)collect)Optional)ref)verifyObject)Deferred
gatherResults)
IConnector
IReactorFDSet)
ClientFactoryProtocol
ServerFactory)needsRunningReactor)contextlog)Failure)ILogContexterrmsg)platform)ClosingProtocol)SkipTestz 127.0.0.1c C s t | dd d }t ||}z.|| |t jkr6| }t |t jt jB d }||d fW | S | W | S | w )a
Ask the platform to allocate a free port on the specified interface, then
release the socket and return the address which was allocated.
@param interface: The local address to try to bind the port on.
@type interface: C{str}
@param type: The socket type which will use the resulting port.
@return: A two-tuple of address and port, like that returned by
L{socket.getsockname}.
r ) socketgetaddrinfobindAF_INET6getsocknamegetnameinfoNI_NUMERICHOSTNI_NUMERICSERVclose) interfacefamilytypeaddrprobesocknamehostname r) H/usr/lib/python3/dist-packages/twisted/internet/test/connectionmixins.pyfindFreePort s
r+ c @ $ e Zd ZdZdZdd Zdd ZdS )ConnectableProtocolab
A protocol to be used with L{runProtocolsWithReactor}.
The protocol and its pair should eventually disconnect from each other.
@ivar reactor: The reactor used in this test.
@ivar disconnectReason: The L{Failure} passed to C{connectionLost}.
@ivar _done: A L{Deferred} which will be fired when the connection is
lost.
Nc C s || _ || _dS )aN
Set attributes on the protocol that are known only externally; this
will be called by L{runProtocolsWithReactor} when this protocol is
instantiated.
@param reactor: The reactor used in this test.
@param done: A L{Deferred} which will be fired when the connection is
lost.
N)reactor_done)selfr. doner) r) r* _setAttributesJ s
z"ConnectableProtocol._setAttributesc C s || _ | jd | `d S N)disconnectReasonr/ callbackr0 reasonr) r) r* connectionLostX s z"ConnectableProtocol.connectionLost)__name__
__module____qualname____doc__r4 r2 r8 r) r) r) r* r- : s
r- c @ e Zd ZdZdd Zdd ZdS )EndpointCreatorzT
Create client and server endpoints that know how to connect to each other.
c C t )z
Return an object providing C{IStreamServerEndpoint} for use in creating
a server to use to establish the connection type to be tested.
NotImplementedErrorr0 r. r) r) r* serverc zEndpointCreator.serverc C r? )z
Return an object providing C{IStreamClientEndpoint} for use in creating
a client to use to establish the connection type to be tested.
r@ )r0 r.
serverAddressr) r) r* clientj rD zEndpointCreator.clientN)r9 r: r; r<