/usr/lib/python3/dist-packages/twisted/internet/__pycache__
NameSizeModeActions
abstract.cpython-310.pyc176100644editdlrm
address.cpython-310.pyc56700644editdlrm
asyncioreactor.cpython-310.pyc99550644editdlrm
base.cpython-310.pyc408700644editdlrm
cfreactor.cpython-310.pyc156380644editdlrm
default.cpython-310.pyc11720644editdlrm
defer.cpython-310.pyc687400644editdlrm
endpoints.cpython-310.pyc733480644editdlrm
epollreactor.cpython-310.pyc69210644editdlrm
error.cpython-310.pyc150360644editdlrm
fdesc.cpython-310.pyc31730644editdlrm
gireactor.cpython-310.pyc40980644editdlrm
glib2reactor.cpython-310.pyc14680644editdlrm
gtk2reactor.cpython-310.pyc25890644editdlrm
gtk3reactor.cpython-310.pyc18690644editdlrm
inotify.cpython-310.pyc108480644editdlrm
interfaces.cpython-310.pyc1173770644editdlrm
kqreactor.cpython-310.pyc85820644editdlrm
main.cpython-310.pyc9750644editdlrm
pollreactor.cpython-310.pyc59600644editdlrm
posixbase.cpython-310.pyc234570644editdlrm
process.cpython-310.pyc286110644editdlrm
protocol.cpython-310.pyc306580644editdlrm
pyuisupport.cpython-310.pyc9730644editdlrm
reactor.cpython-310.pyc19200644editdlrm
selectreactor.cpython-310.pyc53030644editdlrm
serialport.cpython-310.pyc27780644editdlrm
ssl.cpython-310.pyc89290644editdlrm
stdio.cpython-310.pyc9840644editdlrm
task.cpython-310.pyc321410644editdlrm
tcp.cpython-310.pyc466840644editdlrm
testing.cpython-310.pyc333470644editdlrm
threads.cpython-310.pyc42080644editdlrm
tksupport.cpython-310.pyc21690644editdlrm
udp.cpython-310.pyc165840644editdlrm
unix.cpython-310.pyc195310644editdlrm
utils.cpython-310.pyc93270644editdlrm
win32eventreactor.cpython-310.pyc138810644editdlrm
wxreactor.cpython-310.pyc48970644editdlrm
wxsupport.cpython-310.pyc16930644editdlrm
_baseprocess.cpython-310.pyc22160644editdlrm
_dumbwin32proc.cpython-310.pyc116270644editdlrm
_glibbase.cpython-310.pyc117910644editdlrm
_idna.cpython-310.pyc14940644editdlrm
_newtls.cpython-310.pyc87140644editdlrm
_pollingfile.cpython-310.pyc84760644editdlrm
_posixserialport.cpython-310.pyc21910644editdlrm
_posixstdio.cpython-310.pyc53090644editdlrm
_producer_helpers.cpython-310.pyc38670644editdlrm
_resolver.cpython-310.pyc84020644editdlrm
_signals.cpython-310.pyc28240644editdlrm
_sslverify.cpython-310.pyc684120644editdlrm
_threadedselect.cpython-310.pyc117550644editdlrm
_win32serialport.cpython-310.pyc37070644editdlrm
_win32stdio.cpython-310.pyc40240644editdlrm
__init__.cpython-310.pyc6080644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/internet/__pycache__/testing.cpython-310.pyc (33347B)
o b0r@sLdZddlmZddlmZddlmZmZddlm Z m Z ddl m Z m Z ddlmZddlmZmZmZmZdd lmZmZdd lmZmZmZdd lmZdd lmZdd l m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4gdZ5Gdddej6Z7Gddde2j8Z9GdddZ:e e,e"e%GdddZ;Gddde;Ze e!Gd!d"d"Z?e e&e*e)e+e(e'Gd#d$d$Z@e e@D]ZAeeAe@qGd%d&d&e@e.ZBe e*e)e+e(Gd'd(d(ZCGd)d*d*ZDd+d,ZEe e0Gd-d.d.eZFd/S)0zJ Assorted functionality which is commonly useful when writing unit tests. )Sequence)BytesIO)AF_INETAF_INET6)AnyCallable) implementedBy implementer) verifyClass)addresserrorprotocoltask)_dataMustBeBytes isIPv6Address) IPv4Address IPv6Address UNIXAddress)Deferred)UnsupportedAddressFamily) IConnector IConsumerIListeningPort IProtocol IPushProducer IReactorCore IReactorFDSetIReactorSocket IReactorSSL IReactorTCP IReactorUNIX ITransport)Clock) ILogObserver)basic)failure)AccumulatingProtocolLineSendingProtocolFakeDatagramTransportStringTransport StringTransportWithDisconnectionStringIOWithoutClosing_FakeConnector _FakePort MemoryReactorMemoryReactorClockRaisingMemoryReactorNonStreamingProducerwaitUntilAllDisconnectedEventLoggingObserverc@s@eZdZdZdZZdZdZdZdZ ddZ ddZ d d Z dS) r&ad 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. rNcCsBd|_|jdur|jjdur|jj}d|j_||dSdSdSN)madefactoryprotocolConnectionMadecallbackselfdr>:/usr/lib/python3/dist-packages/twisted/internet/testing.pyconnectionMadeTs z#AccumulatingProtocol.connectionMadecCs|j|7_dSN)datar<rBr>r>r? dataReceived[sz!AccumulatingProtocol.dataReceivedcCs6d|_||_|jdur|jd}|_|ddSdSr5)closed closedReasonclosedDeferredr:)r<reasonr=r>r>r?connectionLost^s  z#AccumulatingProtocol.connectionLost) __name__ __module__ __qualname____doc__r7rErFrGrBr8r@rDrIr>r>r>r?r&<s r&c@s2eZdZdZd ddZddZddZd d Zd S) r'FTcCs|dd|_g|_||_dSrA)linesresponsestart)r<rNrPr>r>r?__init__is zLineSendingProtocol.__init__cCs$|jr|jD] }||qdSdSrA)rPrNsendLiner<liner>r>r?r@ns   z"LineSendingProtocol.connectionMadecCs2|js|jD]}||qg|_|j|dSrA)rPrNrRrOappendrSr>r>r? lineReceivedss   z LineSendingProtocol.lineReceivedcC d|_dSNT)lostConn)r<rHr>r>r?rIz z"LineSendingProtocol.connectionLostN)T)rJrKrLrYrQr@rVrIr>r>r>r?r'fs   r'c@s&eZdZeZddZefddZdS)r(cC g|_dSrA)writtenr<r>r>r?rQrZzFakeDatagramTransport.__init__cCs|j||fdSrA)r\rU)r<packetaddrr>r>r?writeszFakeDatagramTransport.writeN)rJrKrLobjectnoAddrrQr`r>r>r>r?r(~sr(c@seZdZdZdZdZdZdZdZdZ dZ d#ddZ ddZ d d Z d d Zd dZddZddZddZddZddZddZddZddZdd Zd!d"ZdS)$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 producingcCs4||dur ||_|dur||_d|_||_dSrX)clearhostAddrpeerAddr connected_lenient)r< hostAddress peerAddresslenientr>r>r?rQs zStringTransport.__init__cCs t|_dS)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)rior]r>r>r?rds zStringTransport.clearcCs |jS)aN 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} )rlgetvaluer]r>r>r?values zStringTransport.valuecCst||j|dSrA)rrlr`rCr>r>r?r`szStringTransport.writecCs|jd|dS)Nr4)rlr`joinrCr>r>r? writeSequenceszStringTransport.writeSequencecC d|_dS)z~ Close the connection. Does nothing besides toggle the C{disconnecting} instance variable to C{True}. TN) disconnectingr]r>r>r?loseConnection zStringTransport.loseConnectioncCd|_|dS)z Abort the connection. Same as C{loseConnection}, but also toggles the C{aborted} instance variable to C{True}. TN) disconnectedrsr]r>r>r?abortConnections zStringTransport.abortConnectioncC|jdur tdddS|jS)NTCPz 192.168.1.1i1)rfr rr]r>r>r?getPeer zStringTransport.getPeercCrx)Nryz10.0.0.1i90)rer rr]r>r>r?getHostr{zStringTransport.getHostcCs"|jdur td||_||_dS)NzCannot register two producersproducer RuntimeError streaming)r<r~rr>r>r?registerProducer   z StringTransport.registerProducercCs"|jdur tdd|_d|_dS)Nz5Cannot unregister a producer unless one is registeredr}r]r>r>r?unregisterProducerrz"StringTransport.unregisterProducercCs*|jr |js td|jdkrtddS)Nz,Cannot resume producing after loseConnectionstoppedz Cannot resume a stopped producer)rrrhr producerStater]r>r>r? _checkStates  zStringTransport._checkStatecC|d|_dS)Npausedrrr]r>r>r?pauseProducing zStringTransport.pauseProducingcCrW)Nr)rr]r>r>r? stopProducing rZzStringTransport.stopProducingcCr)Nrcrr]r>r>r?resumeProducing#rzStringTransport.resumeProducing)NNF)rJrKrLrMrrrvr~rrerfrrQrdrnr`rprsrwrzr|rrrrrrr>r>r>r?r)s03    r)c@s"eZdZUdZeed<ddZdS)r*zt A L{StringTransport} which on disconnection will trigger the connection lost on the attached protocol. r cCs,|jrd|_|jttddSdS)NFzBye.)rgr rIr%Failurer ConnectionDoner]r>r>r?rs0sz/StringTransportWithDisconnection.loseConnectionN)rJrKrLrMr__annotations__rsr>r>r>r?r*(s  r*c@seZdZdZddZdS)r+z) A BytesIO that can't be closed. cCdS)z Do nothing. Nr>r]r>r>r?close;zStringIOWithoutClosing.closeN)rJrKrLrMrr>r>r>r?r+6s r+c@s0eZdZdZddZddZddZdd Zd S) r-z A fake L{IListeningPort} to be used in tests. @ivar _hostAddress: The L{IAddress} this L{IListeningPort} is pretending to be listening on. cC ||_dS)zz @param hostAddress: An L{IAddress} this L{IListeningPort} should pretend to be listening on. N _hostAddress)r<rir>r>r?rQJrtz_FakePort.__init__cCr)zQ Fake L{IListeningPort.startListening} that doesn't do anything. Nr>r]r>r>r?startListeningQrz_FakePort.startListeningcCr)zP Fake L{IListeningPort.stopListening} that doesn't do anything. Nr>r]r>r>r? stopListeningVrz_FakePort.stopListeningcC|jS)zN Fake L{IListeningPort.getHost} that returns our L{IAddress}. rr]r>r>r?r|[z_FakePort.getHostN)rJrKrLrMrQrrr|r>r>r>r?r-As  r-c@s@eZdZdZdZdZddZddZddZd d Z d d Z d S)r,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. FcCr)zs @param address: An L{IAddress} provider that represents this connector's destination. N_address)r<r r>r>r?rQqrtz_FakeConnector.__init__cCrq)zw Implement L{IConnector.stopConnecting} and set L{_FakeConnector.stoppedConnecting} to C{True} TN)stoppedConnectingr]r>r>r?stopConnectingxrtz_FakeConnector.stopConnectingcCrq)z@ Implement L{IConnector.disconnect} as a no-op. TN) _disconnectedr]r>r>r? disconnect z_FakeConnector.disconnectcCr)z= Implement L{IConnector.connect} as a no-op. Nr>r]r>r>r?connectrz_FakeConnector.connectcCr)zp Implement L{IConnector.getDestination} to return the C{address} passed to C{__init__}. rr]r>r>r?getDestinationz_FakeConnector.getDestinationN) rJrKrLrMrrrQrrrrr>r>r>r?r,bs  r,c@s eZdZdZddZddZdDddZd d Zd d Zd dZ dEddZ ddZ de de de deffddZddZde deffddZddZd d!ZdFd#d$ZdGd'd(ZdHd+d,ZdGd-d.Z *dHd/d0ZdId2d3ZdJd4d5Zd6d7Zd8d9Zd:d;Zdd?Zd@dAZ dBdCZ!d*S)Kr.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}. cCstd|_d|_d|_d|_d|_g|_i|_g|_g|_g|_ g|_ g|_ g|_ g|_ g|_g|_t|_t|_dS)z0 Initialize the tracking lists. FTN) hasInstalledrunninghasRun hasStopped hasCrashedwhenRunningHookstriggers tcpClients tcpServers sslClients sslServers unixClients unixServers adoptedPortsadoptedStreamConnections connectorssetreaderswritersr]r>r>r?rQs$ zMemoryReactor.__init__cCrq)zO Fake install callable to emulate reactor module installation. TN)rr]r>r>r?installrzMemoryReactor.install cCtzA Not implemented; raises L{NotImplementedError}. NotImplementedError)r<nametimeoutr>r>r?resolverzMemoryReactor.resolvecCsF|jdusJd|_d|_|jD] \}}}||i|q|dS)a 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)rrrstop)r<fargskwargsr>r>r?runs  zMemoryReactor.runcCsd|_d|_dS)z Fake L{IReactorCore.run}. Sets C{self.running} to L{False}. Sets C{self.hasStopped} to L{True}. FTN)rrr]r>r>r?r zMemoryReactor.stopcCsd|_d|_dS)z Fake L{IReactorCore.crash}. Sets C{self.running} to L{None}, because that feels crashy. Sets C{self.hasCrashed} to L{True}. NT)rrr]r>r>r?crashrzMemoryReactor.crashrcCrrr)r<delayr>r>r?iteraterzMemoryReactor.iteratecCrrr)r< eventTyper>r>r?fireSystemEventrzMemoryReactor.fireSystemEventphasercallable.cOs.|j|i}||g}||||fdS)z Fake L{IReactorCore.run}. Keep track of trigger by appending it to self.triggers[phase][eventType]. N)r setdefaultrU)r<rrrrkw phaseTriggerseventTypeTriggersr>r>r?addSystemEventTrigger%s z#MemoryReactor.addSystemEventTriggercCrrr)r< triggerIDr>r>r?removeSystemEventTrigger1rz&MemoryReactor.removeSystemEventTriggercO|j|||fdS)z Fake L{IReactorCore.callWhenRunning}. Keeps a list of invocations to make in C{self.whenRunningHooks}. N)rrU)r<rrrr>r>r?callWhenRunning7szMemoryReactor.callWhenRunningcCsL|tkr tddd}n|tkrtddd}nt|j|||ft|S)zv Fake L{IReactorSocket.adoptStreamPort}, that logs the call and returns an L{IListeningPort}. ry0.0.0.0::rrrrrrrUr-)r<fileno addressFamilyr8r_r>r>r?adoptStreamPort>szMemoryReactor.adoptStreamPortcCr)z Record the given stream connection in C{adoptedStreamConnections}. @see: L{twisted.internet.interfaces.IReactorSocket.adoptStreamConnection} N)rrUr<fileDescriptorrr8r>r>r?adoptStreamConnectionMsz#MemoryReactor.adoptStreamConnection cCsN|tkr tddd}n|tkrtddd}nt|j||||ft|S)z Fake L{IReactorSocket.adoptDatagramPort}, that logs the call and returns a fake L{IListeningPort}. @see: L{twisted.internet.interfaces.IReactorSocket.adoptDatagramPort} UDPrrrr)r<rrr maxPacketSizer_r>r>r?adoptDatagramPortVszMemoryReactor.adoptDatagramPort2cCsD|j||||ft|rtd||}t|Stdd|}t|S)zm Fake L{IReactorTCP.listenTCP}, that logs the call and returns an L{IListeningPort}. ryr)rrUrrrr-)r<portr8backlog interfacer r>r>r? listenTCPgs   zMemoryReactor.listenTCPNcCsZ|j|||||ft|rttd||}nttd||}|||j||S)zj Fake L{IReactorTCP.connectTCP}, that logs the call and returns an L{IConnector}. ry)rrUrr,rrstartedConnectingr)r<hostrr8r bindAddressconnr>r>r? connectTCPss  zMemoryReactor.connectTCPcCs&|j|||||fttdd|S)zm Fake L{IReactorSSL.listenSSL}, that logs the call and returns an L{IListeningPort}. ryr)rrUr-rr<rr8contextFactoryrrr>r>r? listenSSLszMemoryReactor.listenSSLcCsB|j||||||fttd||}|||j||S)zj Fake L{IReactorSSL.connectSSL}, that logs the call and returns an L{IConnector}. ry)rrUr,rrr)r<rrr8rrrrr>r>r? connectSSLs  zMemoryReactor.connectSSLcCs"|j|||||ftt|S)zo Fake L{IReactorUNIX.listenUNIX}, that logs the call and returns an L{IListeningPort}. )rrUr-rr<r r8rmodewantPIDr>r>r? listenUNIXs zMemoryReactor.listenUNIXcCs:|j||||ftt|}|||j||S)zl Fake L{IReactorUNIX.connectUNIX}, that logs the call and returns an L{IConnector}. )rrUr,rrr)r<r r8rcheckPIDrr>r>r? connectUNIXs    zMemoryReactor.connectUNIXcC|j|dS)zW Fake L{IReactorFDSet.addReader} which adds the reader to a local set. N)raddr<readerr>r>r? addReaderzMemoryReactor.addReadercCr)zg Fake L{IReactorFDSet.removeReader} which removes the reader from a local set. N)rdiscardrr>r>r? removeReaderzMemoryReactor.removeReadercCr)zW Fake L{IReactorFDSet.addWriter} which adds the writer to a local set. N)rrr<writerr>r>r? addWriterrzMemoryReactor.addWritercCr)zg Fake L{IReactorFDSet.removeWriter} which removes the writer from a local set. N)rrrr>r>r? removeWriterrzMemoryReactor.removeWritercC t|jS)zn Fake L{IReactorFDSet.getReaders} which returns a list of readers from the local set. )listrr]r>r>r? getReadersrtzMemoryReactor.getReaderscCr )zn Fake L{IReactorFDSet.getWriters} which returns a list of writers from the local set. )r rr]r>r>r? getWritersrtzMemoryReactor.getWriterscCs|j|jdS)zt Fake L{IReactorFDSet.removeAll} which removed all readers and writers from the local sets. N)rrdrr]r>r>r? removeAlls zMemoryReactor.removeAll)r)r)rrrrNrrrrr)"rJrKrLrMrQrrrrrrrstrrrrrrrrrrrrrrrrrrrr r r r>r>r>r?r.sH8           r.c@seZdZddZdS)r/cCst|t|dSrA)r.rQr"r]r>r>r?rQs zMemoryReactorClock.__init__N)rJrKrLrQr>r>r>r?r/s r/c@speZdZdZdddZddZdd d Zdd d ZdddZ dddZ dddZ d ddZ ddZ ddZ dS)!r0z 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} NcCs||_||_dS)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_connectException)r<listenExceptionconnectExceptionr>r>r?rQs zRaisingMemoryReactor.__init__cC|j)zb Fake L{IReactorSocket.adoptStreamPort}, that raises L{_listenException}. r)r<rrr8r>r>r?rrz$RaisingMemoryReactor.adoptStreamPortrrcCr)zQ Fake L{IReactorTCP.listenTCP}, that raises L{_listenException}. r)r<rr8rrr>r>r?rrzRaisingMemoryReactor.listenTCPrcCr)zS Fake L{IReactorTCP.connectTCP}, that raises L{_connectException}. r)r<rrr8rrr>r>r?rrzRaisingMemoryReactor.connectTCPcCr)zQ Fake L{IReactorSSL.listenSSL}, that raises L{_listenException}. rrr>r>r?rrzRaisingMemoryReactor.listenSSLcCr)zS Fake L{IReactorSSL.connectSSL}, that raises L{_connectException}. r)r<rrr8rrrr>r>r?rszRaisingMemoryReactor.connectSSLrrcCr)zS Fake L{IReactorUNIX.listenUNIX}, that raises L{_listenException}. rrr>r>r?rrzRaisingMemoryReactor.listenUNIXcCr)zU Fake L{IReactorUNIX.connectUNIX}, that raises L{_connectException}. r)r<r r8rrr>r>r?r"rz RaisingMemoryReactor.connectUNIXcCr)ze Fake L{IReactorSocket.adoptDatagramPort}, that raises L{_connectException}. r)r<rrr rr>r>r?r(rz&RaisingMemoryReactor.adoptDatagramPortcCr)zi Fake L{IReactorSocket.adoptStreamConnection}, that raises L{_connectException}. rrr>r>r?r/rz*RaisingMemoryReactor.adoptStreamConnection)NNrrrr)rJrKrLrMrQrrrrrrrrrr>r>r>r?r0s       r0c@s@eZdZdZdZdZddZddZdd Zd d Z d d Z dS)r1z5 A pull producer which writes 10 times only. rFcCs||_t|_dSrA)consumerrresult)r<rr>r>r?rQ?s zNonStreamingProducer.__init__cCsb|jdus |jdkrtd|jd|jf|jd7_|jdkr/|j|dSdS)z/ Write the counter value once. Nrz"BUG: resume after unregister/stop.s%dr6)rcounterrr`r_doner]r>r>r?rCs   z$NonStreamingProducer.resumeProducingcCstd)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.)rr]r>r>r?rPsz#NonStreamingProducer.pauseProducingcCsd|_|j}|`|ddS)zQ Fire a L{Deferred} so that users can wait for this to complete. N)rrr:r;r>r>r?rWszNonStreamingProducer._donecCru)z& Stop all production. TN)rrr]r>r>r?r`s z"NonStreamingProducer.stopProducingN) rJrKrLrMrrrQrrrrr>r>r>r?r17s  r1cs0dfdd}t||_jdddS)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. Ncs"dddDvrdSdS)NTcSsg|]}|jjqSr>) transportrg).0xr>r>r? }sz._check..)rr>lc protocolsr>r?_check|s z(waitUntilAllDisconnected.._checkg{Gz?T)now)r LoopingCallclockrP)reactorr$r%r>r"r?r2hs  r2c@sDeZdZdZddZddZddZdd Zd d Ze d d Z dS)r3a 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} cCr[rA_eventsr]r>r>r?rQrZzEventLoggingObserver.__init__cCr rA)lenr+r]r>r>r?__len__rZzEventLoggingObserver.__len__cCs |j|SrAr*)r<indexr>r>r? __getitem__rZz EventLoggingObserver.__getitem__cCr rA)iterr+r]r>r>r?__iter__rZzEventLoggingObserver.__iter__cCr)z' @see: L{ILogObserver} N)r+rU)r<eventr>r>r?__call__rzEventLoggingObserver.__call__cs(||fddS)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} cs SrA)removeObserverr>obs publisherr>r?s z8EventLoggingObserver.createWithCleanup..) addObserver addCleanup)cls testInstancer7r>r5r?createWithCleanups z&EventLoggingObserver.createWithCleanupN) rJrKrLrMrQr-r/r1r3 classmethodr=r>r>r>r?r3s r3N)GrMcollections.abcrrlrsocketrrtypingrrzope.interfacerr zope.interface.verifyr twisted.internetr r r rtwisted.internet.abstractrrtwisted.internet.addressrrrtwisted.internet.deferrtwisted.internet.errorrtwisted.internet.interfacesrrrrrrrrrrr r!twisted.internet.taskr"twisted.loggerr#twisted.protocolsr$twisted.pythonr%__all__Protocolr& LineReceiverr'r(r)r*r+r-r,r.ifacer/r0r1r2r3r>r>r>r?sZ     8    *    /  I  P1