class documentation

class twisted.internet.testing.MemoryReactor: (source)

Known subclasses: twisted.internet.testing.MemoryReactorClock

Implements interfaces: twisted.internet.interfaces.IReactorCore, twisted.internet.interfaces.IReactorFDSet, twisted.internet.interfaces.IReactorSocket, twisted.internet.interfaces.IReactorSSL, twisted.internet.interfaces.IReactorTCP, twisted.internet.interfaces.IReactorUNIX

View In Hierarchy

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.

Instance Variable hasInstalled Keeps track of whether this reactor has been installed.
Instance Variable running A bool which is True from during startup to during shutdown and False the rest of the time.
Instance Variable hasStopped Keeps track of whether this reactor has been stopped.
Instance Variable hasCrashed Keeps track of whether this reactor has crashed.
Instance Variable whenRunningHooks Keeps track of hooks registered with callWhenRunning.
Instance Variable triggers Keeps track of hooks registered with addSystemEventTrigger.
Instance Variable tcpClients Keeps track of connection attempts (ie, calls to connectTCP).
Instance Variable tcpServers Keeps track of server listen attempts (ie, calls to listenTCP).
Instance Variable sslClients Keeps track of connection attempts (ie, calls to connectSSL).
Instance Variable sslServers Keeps track of server listen attempts (ie, calls to listenSSL).
Instance Variable unixClients Keeps track of connection attempts (ie, calls to connectUNIX).
Instance Variable unixServers Keeps track of server listen attempts (ie, calls to listenUNIX).
Instance Variable adoptedPorts Keeps track of server listen attempts (ie, calls to adoptStreamPort).
Instance Variable adoptedStreamConnections Keeps track of stream-oriented connections added using adoptStreamConnection.
Method __init__ Initialize the tracking lists.
Instance Variable hasRun Undocumented
Instance Variable connectors Undocumented
Instance Variable readers Undocumented
Instance Variable writers Undocumented
Method install Fake install callable to emulate reactor module installation.
Method resolve Not implemented; raises NotImplementedError.
Method run No summary
Method stop Fake IReactorCore.run. Sets self.running to False. Sets self.hasStopped to True.
Method crash Fake IReactorCore.crash. Sets self.running to None, because that feels crashy. Sets self.hasCrashed to True.
Method iterate Not implemented; raises NotImplementedError.
Method fireSystemEvent Not implemented; raises NotImplementedError.
Method addSystemEventTrigger Fake IReactorCore.run. Keep track of trigger by appending it to self.triggers[phase][eventType].
Method removeSystemEventTrigger Not implemented; raises NotImplementedError.
Method callWhenRunning Fake IReactorCore.callWhenRunning. Keeps a list of invocations to make in self.whenRunningHooks.
Method adoptStreamPort Fake IReactorSocket.adoptStreamPort, that logs the call and returns an IListeningPort.
Method adoptStreamConnection Record the given stream connection in adoptedStreamConnections.
Method adoptDatagramPort Fake IReactorSocket.adoptDatagramPort, that logs the call and returns a fake IListeningPort.
Method listenTCP Fake IReactorTCP.listenTCP, that logs the call and returns an IListeningPort.
Method connectTCP Fake IReactorTCP.connectTCP, that logs the call and returns an IConnector.
Method listenSSL Fake IReactorSSL.listenSSL, that logs the call and returns an IListeningPort.
Method connectSSL Fake IReactorSSL.connectSSL, that logs the call and returns an IConnector.
Method listenUNIX Fake IReactorUNIX.listenUNIX, that logs the call and returns an IListeningPort.
Method connectUNIX Fake IReactorUNIX.connectUNIX, that logs the call and returns an IConnector.
Method addReader Fake IReactorFDSet.addReader which adds the reader to a local set.
Method removeReader Fake IReactorFDSet.removeReader which removes the reader from a local set.
Method addWriter Fake IReactorFDSet.addWriter which adds the writer to a local set.
Method removeWriter Fake IReactorFDSet.removeWriter which removes the writer from a local set.
Method getReaders Fake IReactorFDSet.getReaders which returns a list of readers from the local set.
Method getWriters Fake IReactorFDSet.getWriters which returns a list of writers from the local set.
Method removeAll Fake IReactorFDSet.removeAll which removed all readers and writers from the local sets.
hasInstalled = (source)
Keeps track of whether this reactor has been installed.
(type: bool)
running = (source)
Keeps track of whether this reactor is running.
(type: bool)
hasStopped = (source)
Keeps track of whether this reactor has been stopped.
(type: bool)
hasCrashed = (source)
Keeps track of whether this reactor has crashed.
(type: bool)
whenRunningHooks = (source)
Keeps track of hooks registered with callWhenRunning.
(type: list)
triggers = (source)
Keeps track of hooks registered with addSystemEventTrigger.
(type: dict)
tcpClients = (source)
Keeps track of connection attempts (ie, calls to connectTCP).
(type: list)
tcpServers = (source)
Keeps track of server listen attempts (ie, calls to listenTCP).
(type: list)
sslClients = (source)
Keeps track of connection attempts (ie, calls to connectSSL).
(type: list)
sslServers = (source)
Keeps track of server listen attempts (ie, calls to listenSSL).
(type: list)
unixClients = (source)
Keeps track of connection attempts (ie, calls to connectUNIX).
(type: list)
unixServers = (source)
Keeps track of server listen attempts (ie, calls to listenUNIX).
(type: list)
adoptedPorts = (source)
Keeps track of server listen attempts (ie, calls to adoptStreamPort).
(type: list)
adoptedStreamConnections = (source)
Keeps track of stream-oriented connections added using adoptStreamConnection.
(type: list)
def __init__(self): (source)

Initialize the tracking lists.

hasRun = (source)

Undocumented

(type: bool)
connectors = (source)

Undocumented

(type: list)
readers = (source)

Undocumented

(type: set)
writers = (source)

Undocumented

(type: set)
def install(self): (source)

Fake install callable to emulate reactor module installation.

def resolve(self, name, timeout=10): (source)
def run(self): (source)

Fake IReactorCore.run. Sets self.running to True, runs all of the hooks passed to self.callWhenRunning, then calls self.stop to simulate a request to stop the reactor. Sets self.hasRun to True.

def stop(self): (source)

Fake IReactorCore.run. Sets self.running to False. Sets self.hasStopped to True.

def crash(self): (source)

Fake IReactorCore.crash. Sets self.running to None, because that feels crashy. Sets self.hasCrashed to True.

def iterate(self, delay=0): (source)
def fireSystemEvent(self, eventType): (source)
def addSystemEventTrigger(self, phase, eventType, callable, *args, **kw): (source)

Fake IReactorCore.run. Keep track of trigger by appending it to self.triggers[phase][eventType].

ParametersphaseUndocumented (type: str)
eventTypeUndocumented (type: str)
callableUndocumented (type: Callable[..., Any])
argsUndocumented
kwUndocumented
def removeSystemEventTrigger(self, triggerID): (source)
def callWhenRunning(self, callable, *args, **kw): (source)

Fake IReactorCore.callWhenRunning. Keeps a list of invocations to make in self.whenRunningHooks.

ParameterscallableUndocumented (type: Callable[..., Any])
argsUndocumented
kwUndocumented
def adoptStreamPort(self, fileno, addressFamily, factory): (source)
def adoptStreamConnection(self, fileDescriptor, addressFamily, factory): (source)

Record the given stream connection in adoptedStreamConnections.

See Alsotwisted.internet.interfaces.IReactorSocket.adoptStreamConnection
def adoptDatagramPort(self, fileno, addressFamily, protocol, maxPacketSize=8192): (source)
def listenTCP(self, port, factory, backlog=50, interface=''): (source)

Fake IReactorTCP.listenTCP, that logs the call and returns an IListeningPort.

def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): (source)

Fake IReactorTCP.connectTCP, that logs the call and returns an IConnector.

def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''): (source)

Fake IReactorSSL.listenSSL, that logs the call and returns an IListeningPort.

def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None): (source)

Fake IReactorSSL.connectSSL, that logs the call and returns an IConnector.

def listenUNIX(self, address, factory, backlog=50, mode=438, wantPID=0): (source)
def connectUNIX(self, address, factory, timeout=30, checkPID=0): (source)

Fake IReactorUNIX.connectUNIX, that logs the call and returns an IConnector.

def addReader(self, reader): (source)

Fake IReactorFDSet.addReader which adds the reader to a local set.

def removeReader(self, reader): (source)

Fake IReactorFDSet.removeReader which removes the reader from a local set.

def addWriter(self, writer): (source)

Fake IReactorFDSet.addWriter which adds the writer to a local set.

def removeWriter(self, writer): (source)

Fake IReactorFDSet.removeWriter which removes the writer from a local set.

def getReaders(self): (source)

Fake IReactorFDSet.getReaders which returns a list of readers from the local set.

def getWriters(self): (source)

Fake IReactorFDSet.getWriters which returns a list of writers from the local set.

def removeAll(self): (source)

Fake IReactorFDSet.removeAll which removed all readers and writers from the local sets.

API Documentation for Twisted, generated by pydoctor 20.12.1 at 2021-02-28 19:53:36.