class documentation

class 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.
Method __init__ Initialize the tracking lists.
Method add​Reader Fake IReactorFDSet.addReader which adds the reader to a local set.
Method add​System​Event​Trigger Fake IReactorCore.run. Keep track of trigger by appending it to self.triggers[phase][eventType].
Method add​Writer Fake IReactorFDSet.addWriter which adds the writer to a local set.
Method adopt​Datagram​Port Fake IReactorSocket.adoptDatagramPort, that logs the call and returns a fake IListeningPort.
Method adopt​Stream​Connection Record the given stream connection in adoptedStreamConnections.
Method adopt​Stream​Port Fake IReactorSocket.adoptStreamPort, that logs the call and returns an IListeningPort.
Method call​When​Running Fake IReactorCore.callWhenRunning. Keeps a list of invocations to make in self.whenRunningHooks.
Method connect​SSL Fake IReactorSSL.connectSSL, that logs the call and returns an IConnector.
Method connect​TCP Fake IReactorTCP.connectTCP, that logs the call and returns an IConnector.
Method connect​UNIX Fake IReactorUNIX.connectUNIX, that logs the call and returns an IConnector.
Method crash Fake IReactorCore.crash. Sets self.running to None, because that feels crashy. Sets self.hasCrashed to True.
Method fire​System​Event Not implemented; raises NotImplementedError.
Method get​Readers Fake IReactorFDSet.getReaders which returns a list of readers from the local set.
Method get​Writers Fake IReactorFDSet.getWriters which returns a list of writers from the local set.
Method install Fake install callable to emulate reactor module installation.
Method iterate Not implemented; raises NotImplementedError.
Method listen​SSL Fake IReactorSSL.listenSSL, that logs the call and returns an IListeningPort.
Method listen​TCP Fake IReactorTCP.listenTCP, that logs the call and returns an IListeningPort.
Method listen​UNIX Fake IReactorUNIX.listenUNIX, that logs the call and returns an IListeningPort.
Method remove​All Fake IReactorFDSet.removeAll which removed all readers and writers from the local sets.
Method remove​Reader Fake IReactorFDSet.removeReader which removes the reader from a local set.
Method remove​System​Event​Trigger Not implemented; raises NotImplementedError.
Method remove​Writer Fake IReactorFDSet.removeWriter which removes the writer from a local set.
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.
Instance Variable adopted​Ports Keeps track of server listen attempts (ie, calls to adoptStreamPort).
Instance Variable adopted​Stream​Connections Keeps track of stream-oriented connections added using adoptStreamConnection.
Instance Variable connectors Undocumented
Instance Variable has​Crashed Keeps track of whether this reactor has crashed.
Instance Variable has​Installed Keeps track of whether this reactor has been installed.
Instance Variable has​Run Undocumented
Instance Variable has​Stopped Keeps track of whether this reactor has been stopped.
Instance Variable readers Undocumented
Instance Variable running Keeps track of whether this reactor is running.
Instance Variable ssl​Clients Keeps track of connection attempts (ie, calls to connectSSL).
Instance Variable ssl​Servers Keeps track of server listen attempts (ie, calls to listenSSL).
Instance Variable tcp​Clients Keeps track of connection attempts (ie, calls to connectTCP).
Instance Variable tcp​Servers Keeps track of server listen attempts (ie, calls to listenTCP).
Instance Variable triggers Keeps track of hooks registered with addSystemEventTrigger.
Instance Variable unix​Clients Keeps track of connection attempts (ie, calls to connectUNIX).
Instance Variable unix​Servers Keeps track of server listen attempts (ie, calls to listenUNIX).
Instance Variable when​Running​Hooks Keeps track of hooks registered with callWhenRunning.
Instance Variable writers Undocumented
def __init__(self): (source)
Initialize the tracking lists.
def addReader(self, reader): (source)
Fake IReactorFDSet.addReader which adds the reader to a local set.
def addSystemEventTrigger(self, phase, eventType, callable, *args, **kw): (source)
Fake IReactorCore.run. Keep track of trigger by appending it to self.triggers[phase][eventType].
Parameters
phase:strUndocumented
event​Type:strUndocumented
callable:Callable[..., Any]Undocumented
*argsUndocumented
**kwUndocumented
def addWriter(self, writer): (source)
Fake IReactorFDSet.addWriter which adds the writer to a local set.
def adoptDatagramPort(self, fileno, addressFamily, protocol, maxPacketSize=8192): (source)
def adoptStreamConnection(self, fileDescriptor, addressFamily, factory): (source)
Record the given stream connection in adoptedStreamConnections.
See Also
twisted.internet.interfaces.IReactorSocket.adoptStreamConnection
def adoptStreamPort(self, fileno, addressFamily, factory): (source)
def callWhenRunning(self, callable, *args, **kw): (source)
Fake IReactorCore.callWhenRunning. Keeps a list of invocations to make in self.whenRunningHooks.
Parameters
callable:Callable[..., Any]Undocumented
*argsUndocumented
**kwUndocumented
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None): (source)
Fake IReactorSSL.connectSSL, that logs the call and returns an IConnector.
def connectTCP(self, host, port, factory, timeout=30, bindAddress=None): (source)
Fake IReactorTCP.connectTCP, that logs the call and returns an IConnector.
def connectUNIX(self, address, factory, timeout=30, checkPID=0): (source)
Fake IReactorUNIX.connectUNIX, that logs the call and returns an IConnector.
def crash(self): (source)
Fake IReactorCore.crash. Sets self.running to None, because that feels crashy. Sets self.hasCrashed to True.
def fireSystemEvent(self, eventType): (source)
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 install(self): (source)
Fake install callable to emulate reactor module installation.
def iterate(self, delay=0): (source)
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''): (source)
Fake IReactorSSL.listenSSL, that logs the call and returns an IListeningPort.
def listenTCP(self, port, factory, backlog=50, interface=''): (source)
Fake IReactorTCP.listenTCP, that logs the call and returns an IListeningPort.
def listenUNIX(self, address, factory, backlog=50, mode=438, wantPID=0): (source)
def removeAll(self): (source)
Fake IReactorFDSet.removeAll which removed all readers and writers from the local sets.
def removeReader(self, reader): (source)
Fake IReactorFDSet.removeReader which removes the reader from a local set.
def removeSystemEventTrigger(self, triggerID): (source)
def removeWriter(self, writer): (source)
Fake IReactorFDSet.removeWriter which removes the writer from a local set.
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.
adoptedPorts: list = (source)
Keeps track of server listen attempts (ie, calls to adoptStreamPort).
adoptedStreamConnections: list = (source)
Keeps track of stream-oriented connections added using adoptStreamConnection.
connectors: list = (source)

Undocumented

hasCrashed: bool = (source)
Keeps track of whether this reactor has crashed.
hasInstalled: bool = (source)
Keeps track of whether this reactor has been installed.
hasRun: bool = (source)

Undocumented

hasStopped: bool = (source)
Keeps track of whether this reactor has been stopped.
readers = (source)

Undocumented

running: bool = (source)
Keeps track of whether this reactor is running.
sslClients: list = (source)
Keeps track of connection attempts (ie, calls to connectSSL).
sslServers: list = (source)
Keeps track of server listen attempts (ie, calls to listenSSL).
tcpClients: list = (source)
Keeps track of connection attempts (ie, calls to connectTCP).
tcpServers: list = (source)
Keeps track of server listen attempts (ie, calls to listenTCP).
triggers: dict = (source)
Keeps track of hooks registered with addSystemEventTrigger.
unixClients: list = (source)
Keeps track of connection attempts (ie, calls to connectUNIX).
unixServers: list = (source)
Keeps track of server listen attempts (ie, calls to listenUNIX).
whenRunningHooks: list = (source)
Keeps track of hooks registered with callWhenRunning.
writers = (source)

Undocumented