Part of twisted.internet.abstract View Source View In Hierarchy
Known subclasses: twisted.internet._posixserialport.SerialPort, twisted.internet._win32serialport.SerialPort, twisted.internet.base.BasePort, twisted.internet.process.ProcessReader, twisted.internet.process.ProcessWriter, twisted.internet.process.PTYProcess, twisted.internet.tcp.Connection
Implements interfaces: twisted.internet.interfaces.IConsumer, twisted.internet.interfaces.IHalfCloseableDescriptor, twisted.internet.interfaces.IProducer, twisted.internet.interfaces.IReadWriteDescriptor, twisted.internet.interfaces.ITransport
An object which can be operated on by select().
This is an abstract superclass of all objects which may be notified when they are readable or writable; e.g. they have a file-descriptor that is valid to be passed to select(2).Method | __init__ | Undocumented |
Method | connectionLost | The connection was lost. |
Method | writeSomeData | Write as much as possible of the given data, immediately. |
Method | doRead | Called when data is avaliable for reading. |
Method | doWrite | Called when data can be written. |
Method | writeConnectionLost | Indicates write connection was lost. |
Method | readConnectionLost | Indicates read connection was lost. |
Method | write | Reliably write some data. |
Method | writeSequence | Reliably write a sequence of data. |
Method | loseConnection | Close the connection at the next available opportunity. |
Method | loseWriteConnection | Undocumented |
Method | stopReading | Stop waiting for read availability. |
Method | stopWriting | Stop waiting for write availability. |
Method | startReading | Start waiting for read availability. |
Method | startWriting | Start waiting for write availability. |
Method | registerProducer | Register to receive data from a producer. |
Method | unregisterProducer | Stop consuming data from a producer, without disconnecting. |
Method | stopConsuming | Stop consuming data. |
Method | resumeProducing | Undocumented |
Method | pauseProducing | Undocumented |
Method | stopProducing | Stop producing data. |
Method | fileno | File Descriptor number for select(). |
Method | _postLoseConnection | Called after a loseConnection(), when all data has been written. |
Method | _closeWriteConnection | Undocumented |
Inherited from Logger:
Method | logPrefix | Override this method to insert custom logging behavior. Its return value will be inserted in front of every line. It may be called more times than the number of output lines. |
Inherited from Ephemeral:
Method | __getstate__ | Undocumented |
Method | __setstate__ | Undocumented |
The connection was lost.
This is called when the connection on a selectable object has been lost. It will be called whether the connection was closed explicitly, an exception occurred in an event handler, or the other end of the connection closed it first.
Clean up state here, but make sure to call back up to FileDescriptor.Write as much as possible of the given data, immediately.
This is called to invoke the lower-level writing functionality, such as a socket's send() method, or a file's write(); this method returns an integer. If positive, it is the number of bytes written; if negative, it indicates the connection was lost.Called when data is avaliable for reading.
Subclasses must override this method. The result will be interpreted in the same way as a result of doWrite().Called when data can be written.
A result that is true (which will be a negative number) implies the connection was lost. A false result implies the connection is still there; a result of 0 implies no write was done, and a result of None indicates that a write was done.Called after a loseConnection(), when all data has been written.
Whatever this returns is then returned by doWrite.Reliably write some data.
The data is buffered until the underlying file descriptor is ready for writing. If there is more thanself.bufferSize
data in the
buffer and this descriptor has a registered streaming producer, its
pauseProducing()
method will be called.
Reliably write a sequence of data.
Currently, this is a convenience method roughly equivalent to:for chunk in iovec: fd.write(chunk)
It may have a more efficient implementation at a later time or in a different reactor.
As with thewrite()
method, if a buffer size limit is
reached and a streaming producer is registered, it will be paused until the
buffered data is written to the underlying file descriptor.
Close the connection at the next available opportunity.
Call this to cause this FileDescriptor to lose its connection. It will first write any data that it has buffered.
If there is data buffered yet to be written, this method will cause the transport to lose its connection as soon as it's done flushing its write buffer. If you have a producer registered, the connection won't be closed until the producer is finished. Therefore, make sure you unregister your producer when it's finished, or the connection will never close.Stop waiting for read availability.
Call this to remove this selectable from being notified when it is ready for reading.Stop waiting for write availability.
Call this to remove this selectable from being notified when it is ready for writing.Start waiting for write availability.
Call this to have this FileDescriptor be notified whenever it is ready for writing.Register to receive data from a producer.
This sets this selectable to be a consumer for a producer. When this selectable runs out of data on a write() call, it will ask the producer to resumeProducing(). When the FileDescriptor's internal data buffer is filled, it will ask the producer to pauseProducing(). If the connection is lost, FileDescriptor calls producer's stopProducing() method.
If streaming is true, the producer should provide the IPushProducer interface. Otherwise, it is assumed that producer provides the IPullProducer interface. In this case, the producer won't be asked to pauseProducing(), but it has to be careful to write() data only when its resumeProducing() method is called.Stop consuming data.
This is called when a producer has lost its connection, to tell the consumer to go lose its connection (and break potential circular references).Stop producing data.
This tells a producer that its consumer has died, so it must stop producing data for good.File Descriptor number for select().
This method must be overridden or assigned in subclasses to indicate a valid file descriptor for the operating system.