Class t.i.b.ReactorBase(object):

Part of twisted.internet.base View Source View In Hierarchy

Known subclasses: twisted.internet.default.PosixReactorBase, twisted.internet.iocpreactor.reactor.IOCPReactor

Implements interfaces: twisted.internet.interfaces.IReactorCore, twisted.internet.interfaces.IReactorPluggableResolver, twisted.internet.interfaces.IReactorThreads, twisted.internet.interfaces.IReactorTime

Default base class for Reactors.
Instance Variables_stoppedA flag which is true between paired calls to reactor.run and reactor.stop. This should be replaced with an explicit state machine. (type: bool )
_justStoppedA flag which is true between the time reactor.stop is called and the time the shutdown system event is fired. This is used to determine whether that event should be fired after each iteration through the mainloop. This should be replaced with an explicit state machine. (type: bool )
_startedA flag which is true from the time reactor.run is called until the time reactor.run returns. This is used to prevent calls to reactor.run on a running reactor. This should be replaced with an explicit state machine. (type: bool )
runningSee IReactorCore.running
Line # Kind Name Docs
426 Method __init__ Undocumented
452 Method installWaker Undocumented
456 Method installResolver Set the internal resolver to use to for name lookups.
462 Method wakeUp Wake up the event loop.
470 Method doIteration Do one iteration over the readers and writers which have been added.
477 Method addReader Undocumented
481 Method addWriter Undocumented
485 Method removeReader Undocumented
489 Method removeWriter Undocumented
493 Method removeAll Undocumented
498 Method getReaders Undocumented
503 Method getWriters Undocumented
508 Method resolve Return a Deferred that will resolve a hostname.
521 Method stop See twisted.internet.interfaces.IReactorCore.stop.
532 Method crash See twisted.internet.interfaces.IReactorCore.crash.
545 Method sigInt Handle a SIGINT interrupt.
551 Method sigBreak Handle a SIGBREAK interrupt.
557 Method sigTerm Handle a SIGTERM interrupt.
563 Method disconnectAll Disconnect every reader, and writer in the system.
573 Method iterate See twisted.internet.interfaces.IReactorCore.iterate.
580 Method fireSystemEvent See twisted.internet.interfaces.IReactorCore.fireSystemEvent.
588 Method addSystemEventTrigger See twisted.internet.interfaces.IReactorCore.addSystemEventTrigger.
598 Method removeSystemEventTrigger See twisted.internet.interfaces.IReactorCore.removeSystemEventTrigger.
605 Method callWhenRunning See twisted.internet.interfaces.IReactorCore.callWhenRunning.
614 Method startRunning Method called when reactor starts: do some initialization and fire
648 Method callLater See twisted.internet.interfaces.IReactorTime.callLater.
684 Method cancelCallLater See twisted.internet.interfaces.IReactorTime.cancelCallLater.
692 Method getDelayedCalls Return all the outstanding delayed calls in the system.
708 Method timeout Undocumented
718 Method runUntilCurrent Run all pending timed calls.
871 Method callFromThread 0 See twisted.internet.interfaces.IReactorThreads.callFromThread.
900 Method callInThread See twisted.internet.interfaces.IReactorThreads.callInThread.
908 Method suggestThreadPoolSize See twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize.
919 Method callFromThread Cause a function to be executed by the reactor thread.
637 Method _reallyStartRunning Method called to transition to the running state. This should happen
661 Method _moveCallLaterSooner Undocumented
681 Method _cancelCallLater Undocumented
699 Method _insertNewDelayedCalls Undocumented
783 Method _checkProcessArgs Check for valid arguments and environment to spawnProcess.
866 Method _initThreads Undocumented
882 Method _initThreadPool Create the threadpool accessible with callFromThread.
892 Method _stopThreadPool Stop the reactor threadpool.
def __init__(self): (source)
Undocumented
def installWaker(self): (source)
Undocumented
def installResolver(self, resolver): (source)
Set the internal resolver to use to for name lookups.
ParametersresolverThe new resolver to use. (type: An object implementing the IResolverSimple interface )
ReturnsThe previously installed resolver.
def wakeUp(self): (source)
Wake up the event loop.
def doIteration(self, delay): (source)
Do one iteration over the readers and writers which have been added.
def addReader(self, reader): (source)
Undocumented
def addWriter(self, writer): (source)
Undocumented
def removeReader(self, reader): (source)
Undocumented
def removeWriter(self, writer): (source)
Undocumented
def removeAll(self): (source)
Undocumented
def getReaders(self): (source)
Undocumented
def getWriters(self): (source)
Undocumented
def resolve(self, name, timeout=(1, 3, 11, 45)): (source)
Return a Deferred that will resolve a hostname.
def stop(self): (source)
See twisted.internet.interfaces.IReactorCore.stop.
def crash(self): (source)

See twisted.internet.interfaces.IReactorCore.crash.

Reset reactor state tracking attributes and re-initialize certain state-transition helpers which were set up in __init__ but later destroyed (through use).
def sigInt(self, *args): (source)
Handle a SIGINT interrupt.
def sigBreak(self, *args): (source)
Handle a SIGBREAK interrupt.
def sigTerm(self, *args): (source)
Handle a SIGTERM interrupt.
def disconnectAll(self): (source)
Disconnect every reader, and writer in the system.
def iterate(self, delay=0): (source)
See twisted.internet.interfaces.IReactorCore.iterate.
def fireSystemEvent(self, eventType): (source)
See twisted.internet.interfaces.IReactorCore.fireSystemEvent.
def addSystemEventTrigger(self, _phase, _eventType, _f, *args, **kw): (source)
See twisted.internet.interfaces.IReactorCore.addSystemEventTrigger.
def removeSystemEventTrigger(self, triggerID): (source)
See twisted.internet.interfaces.IReactorCore.removeSystemEventTrigger.
def callWhenRunning(self, _callable, *args, **kw): (source)
See twisted.internet.interfaces.IReactorCore.callWhenRunning.
def startRunning(self): (source)

Method called when reactor starts: do some initialization and fire startup events.

Don't call this directly, call reactor.run() instead: it should take care of calling this.

This method is somewhat misnamed. The reactor will not necessarily be in the running state by the time this method returns. The only guarantee is that it will be on its way to the running state.
def _reallyStartRunning(self): (source)
Method called to transition to the running state. This should happen in the during startup event trigger phase.
def callLater(self, _seconds, _f, *args, **kw): (source)
See twisted.internet.interfaces.IReactorTime.callLater.
def _moveCallLaterSooner(self, tple): (source)
Undocumented
def _cancelCallLater(self, tple): (source)
Undocumented
def cancelCallLater(self, callID): (source)
See twisted.internet.interfaces.IReactorTime.cancelCallLater.
def getDelayedCalls(self): (source)
Return all the outstanding delayed calls in the system. They are returned in no particular order. This method is not efficient -- it is really only meant for test cases.
def _insertNewDelayedCalls(self): (source)
Undocumented
def timeout(self): (source)
Undocumented
def runUntilCurrent(self): (source)
Run all pending timed calls.
def _checkProcessArgs(self, args, env): (source)
Check for valid arguments and environment to spawnProcess.
ReturnsA two element tuple giving values to use when creating the process. The first element of the tuple is a list of str giving the values for argv of the child process. The second element of the tuple is either None if env was None or a dict mapping str environment keys to str environment values.
def _initThreads(self): (source)
Undocumented
def callFromThread 0(self, f, *args, **kw): (source)
See twisted.internet.interfaces.IReactorThreads.callFromThread.
def _initThreadPool(self): (source)
Create the threadpool accessible with callFromThread.
def _stopThreadPool(self): (source)
Stop the reactor threadpool.
def callInThread(self, _callable, *args, **kwargs): (source)
See twisted.internet.interfaces.IReactorThreads.callInThread.
def suggestThreadPoolSize(self, size): (source)
See twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize.
def callFromThread(self, f, *args, **kw): (source)

Cause a function to be executed by the reactor thread.

Use this method when you want to run a function in the reactor's thread from another thread. Calling callFromThread should wake up the main thread (where reactor.run() is executing) and run the given callable in that thread.

Obviously, the callable must be thread safe. (If you want to call a function in the next mainloop iteration, but you're in the same thread, use callLater with a delay of 0.)
API Documentation for Twisted, generated by pydoctor at 2008-10-26 16:12:37.