Home | Trees | Index | Help |
|
---|
Package twisted :: Package internet :: Module abstract :: Class FileDescriptor |
|
Ephemeral
--+ |Logger
--+ | FileDescriptor
BasePort
,
Connection
,
Process
,
ProcessReader
,
ProcessWriter
,
PTYProcess
,
SerialPort
,
SerialPort
,
StandardIO
,
StandardIOWriter
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 Summary | |
---|---|
__init__(self,
reactor)
| |
Called after a loseConnection(), when all data has been written. | |
The connection was lost. | |
Called when data is available for writing. | |
File Descriptor number for select(). | |
Close the connection at the next available opportunity. | |
pauseProducing(self)
| |
Register to receive data from a producer. | |
resumeProducing(self)
| |
Start waiting for read availability. | |
Start waiting for write availability. | |
Stop consuming data. | |
stopProducing(self)
| |
Stop waiting for read availability. | |
Stop waiting for write availability. | |
Stop consuming data from a producer, without disconnecting. | |
Reliably write some data. | |
writeSequence(self,
iovec)
| |
Write as much as possible of the given data, immediately. | |
Inherited from Logger | |
Override this method to insert custom logging behavior. | |
Inherited from Ephemeral | |
| |
|
Class Variable Summary | |
---|---|
tuple |
__implements__ = (<class twisted.internet.interfaces.IPr...
|
int |
bufferSize = 65536 |
int |
connected = 0 |
str |
dataBuffer = ''
|
int |
disconnected = 0 |
int |
disconnecting = 0 |
int |
offset = 0 |
NoneType |
producer = None |
int |
producerPaused = 0 |
int |
streamingProducer = 0 |
Method Details |
---|
_postLoseConnection(self)Called after a loseConnection(), when all data has been written. Whatever this returns is then returned by doWrite. |
connectionLost(self, reason)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. |
doWrite(self)Called when data is available for writing. 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. |
fileno(self)File Descriptor number for select(). This method must be overridden or assigned in subclasses to indicate a valid file descriptor for the operating system. |
loseConnection(self)Close the connection at the next available opportunity. Call this to cause this FileDescriptor to lose its connection; if this is in the main loop, it will lose its connection as soon as it's done flushing its write buffer; otherwise, it will wake up the main thread and lose the connection immediately. 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. |
registerProducer(self, producer, streaming)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(). A producer should implement the IProducer interface. FileDescriptor provides some infrastructure for producer methods. |
startReading(self)Start waiting for read availability. |
startWriting(self)Start waiting for write availability. Call this to have this FileDescriptor be notified whenever it is ready for writing. |
stopConsuming(self)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). |
stopReading(self)Stop waiting for read availability. Call this to remove this selectable from being notified when it is ready for reading. |
stopWriting(self)Stop waiting for write availability. Call this to remove this selectable from being notified when it is ready for writing. |
unregisterProducer(self)Stop consuming data from a producer, without disconnecting. |
write(self, data)Reliably write some data. If there is no buffered data this tries to write this data immediately, otherwise this adds data to be written the next time this file descriptor is ready for writing. |
writeSomeData(self, data)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. |
Class Variable Details |
---|
bufferSize
|
connected
|
dataBuffer
|
disconnected
|
disconnecting
|
offset
|
producer
|
producerPaused
|
streamingProducer
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.0 on Sat May 15 20:08:36 2004 | http://epydoc.sf.net |