Table of Contents

Class: FileDescriptor Twisted-0.19.0/twisted/internet/abstract.py

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).

Base Classes   
log.Logger
Methods   
__init__
connectionLost
doWrite
fileno
loseConnection
pauseProducing
registerProducer
resumeProducing
startReading
startWriting
stopConsuming
stopProducing
stopReading
stopWriting
unregisterProducer
write
writeSomeData
  __init__ 
__init__ ( self,  reactor=None )

  connectionLost 
connectionLost ( self )

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 
doWrite ( self )

Called when data is available for writing.

A result that is true (which will be a negtive 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 
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.

Exceptions   
NotImplementedError( str( self.__class__ ) + ' has no fileno method' )
  loseConnection 
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.

  pauseProducing 
pauseProducing ( self )

  registerProducer 
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.

  resumeProducing 
resumeProducing ( self )

  startReading 
startReading ( self )

Start waiting for read availability.

Call this to remove this selectable notified whenever it is ready for reading.

  startWriting 
startWriting ( self )

Start waiting for write availability.

Call this to have this FileDescriptor be notified whenever it is ready for writing.

  stopConsuming 
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).

  stopProducing 
stopProducing ( self )

  stopReading 
stopReading ( self )

Stop waiting for read availability.

Call this to remove this selectable from being notified when it is ready for reading.

  stopWriting 
stopWriting ( self )

Stop waiting for write availability.

Call this to remove this selectable from being notified when it is ready for writing.

  unregisterProducer 
unregisterProducer ( self )

Stop consuming data from a producer, without disconnecting.

  write 
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 
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.

Exceptions   
NotImplementedError("%s does not implement writeSomeData" % str( self.__class__ ) )

Table of Contents

This document was automatically generated on Sun Jul 14 19:52:41 2002 by HappyDoc version 2.0