self.getThreadPool().callInThread(_callable, *args, **kwargs) def suggestThreadPoolSize(self, size): """ See L{lib.twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize}. """ self.getThreadPool().adjustPoolsize(maxthreads=size) else: # This is for signal handlers. def callFromThread(self, f, *args, **kw): assert callable(f), "%s is not callable" % (f,) # See comment in the other callFromThread implementation. self.threadCallQueue.append((f, args, kw)) if platform.supportsThreads(): classImplements(ReactorBase, IReactorThreads) class BaseConnector(styles.Ephemeral): """Basic implementation of connector. State can be: "connecting", "connected", "disconnected" """ implements(IConnector) timeoutID = None factoryStarted = 0 def __init__(self, factory, timeout, reactor): self.state = "disconnected"
class IOverflowError(IArithmeticError): pass class IOverflowWarning(IWarning): pass class IReferenceError(IStandardError): pass class IRuntimeWarning(IWarning): pass class IStopIteration(IException): pass class ISyntaxWarning(IWarning): pass class ISystemError(IStandardError): pass class ISystemExit(IException): pass class ITabError(IIndentationError): pass class ITypeError(IStandardError): pass class IUnboundLocalError(INameError): pass class IUnicodeError(IValueError): pass class IUserWarning(IWarning): pass class IZeroDivisionError(IArithmeticError): pass classImplements(ArithmeticError, IArithmeticError) classImplements(AssertionError, IAssertionError) classImplements(AttributeError, IAttributeError) classImplements(DeprecationWarning, IDeprecationWarning) classImplements(EnvironmentError, IEnvironmentError) classImplements(EOFError, IEOFError) classImplements(Exception, IException) classImplements(FloatingPointError, IFloatingPointError) classImplements(ImportError, IImportError) classImplements(IndentationError, IIndentationError) classImplements(IndexError, IIndexError) classImplements(IOError, IIOError) classImplements(KeyboardInterrupt, IKeyboardInterrupt) classImplements(KeyError, IKeyError) classImplements(LookupError, ILookupError) classImplements(MemoryError, IMemoryError)
pass class IUnicodeError(IValueError): pass class IUserWarning(IWarning): pass class IZeroDivisionError(IArithmeticError): pass classImplements(ArithmeticError, IArithmeticError) classImplements(AssertionError, IAssertionError) classImplements(AttributeError, IAttributeError) classImplements(DeprecationWarning, IDeprecationWarning) classImplements(EnvironmentError, IEnvironmentError) classImplements(EOFError, IEOFError) classImplements(Exception, IException) classImplements(FloatingPointError, IFloatingPointError) classImplements(ImportError, IImportError) classImplements(IndentationError, IIndentationError) classImplements(IndexError, IIndexError) classImplements(IOError, IIOError) classImplements(KeyboardInterrupt, IKeyboardInterrupt) classImplements(KeyError, IKeyError) classImplements(LookupError, ILookupError) classImplements(MemoryError, IMemoryError)
isn't known, return None. Else the value returned must be a timedelta object specifying a whole number of minutes in the range -1439 to 1439 inclusive (1440 = 24*60; the magnitude of the offset must be less than one day). """ def dst(dt): """Return the daylight saving time (DST) adjustment, in minutes east of UTC, or None if DST information isn't known. """ def tzname(dt): """Return the time zone name corresponding to the datetime object as a string. """ def fromutc(dt): """Return an equivalent datetime in self's local time.""" classImplements(timedelta, ITimeDelta) classImplements(date, IDate) classImplements(datetime, IDateTime) classImplements(time, ITime) classImplements(tzinfo, ITZInfo) ## directlyProvides(timedelta, ITimeDeltaClass) ## directlyProvides(date, IDateClass) ## directlyProvides(datetime, IDateTimeClass) ## directlyProvides(time, ITimeClass)
""" Remove all readers and writers, and list of removed L{IReadDescriptor}s and L{IWriteDescriptor}s. Meant for calling from subclasses, to implement removeAll, like:: def removeAll(self): return self._removeAll(self._reads, self._writes) where C{self._reads} and C{self._writes} are iterables. """ removedReaders = set(readers) - self._internalReaders for reader in removedReaders: self.removeReader(reader) removedWriters = set(writers) for writer in removedWriters: self.removeWriter(writer) return list(removedReaders | removedWriters) if sslEnabled: classImplements(PosixReactorBase, IReactorSSL) if unixEnabled: classImplements(PosixReactorBase, IReactorUNIX, IReactorUNIXDatagram) if processEnabled: classImplements(PosixReactorBase, IReactorProcess) __all__ = ["PosixReactorBase"]
def suggestThreadPoolSize(self, size): """ See L{lib.twisted.internet.interfaces.IReactorThreads.suggestThreadPoolSize}. """ self.getThreadPool().adjustPoolsize(maxthreads=size) else: # This is for signal handlers. def callFromThread(self, f, *args, **kw): assert callable(f), "%s is not callable" % (f,) # See comment in the other callFromThread implementation. self.threadCallQueue.append((f, args, kw)) if platform.supportsThreads(): classImplements(ReactorBase, IReactorThreads) class BaseConnector(styles.Ephemeral): """Basic implementation of connector. State can be: "connecting", "connected", "disconnected" """ implements(IConnector) timeoutID = None factoryStarted = 0 def __init__(self, factory, timeout, reactor): self.state = "disconnected"
def getTcpNoDelay(self): return operator.truth(self.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)) def setTcpNoDelay(self, enabled): self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, enabled) def getTcpKeepAlive(self): return operator.truth(self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)) def setTcpKeepAlive(self, enabled): self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, enabled) if SSL: classImplements(Connection, interfaces.ITLSTransport) class BaseClient(Connection): """A base class for client TCP (and similiar) sockets. """ addressFamily = socket.AF_INET socketType = socket.SOCK_STREAM def _finishInit(self, whenDone, skt, error, reactor): """Called by base classes to continue to next stage of initialization.""" if whenDone: Connection.__init__(self, skt, None, reactor) self.doWrite = self.doConnect self.doRead = self.doConnect reactor.callLater(0, whenDone) else:
return operator.truth( self.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)) def setTcpNoDelay(self, enabled): self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, enabled) def getTcpKeepAlive(self): return operator.truth( self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE)) def setTcpKeepAlive(self, enabled): self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, enabled) if SSL: classImplements(Connection, interfaces.ITLSTransport) class BaseClient(Connection): """A base class for client TCP (and similiar) sockets. """ addressFamily = socket.AF_INET socketType = socket.SOCK_STREAM def _finishInit(self, whenDone, skt, error, reactor): """Called by base classes to continue to next stage of initialization.""" if whenDone: Connection.__init__(self, skt, None, reactor) self.doWrite = self.doConnect self.doRead = self.doConnect reactor.callLater(0, whenDone)