t.i.a._ConsumerMixin(object) : class documentation

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

Known subclasses: twisted.internet.abstract.FileDescriptor, twisted.internet.iocpreactor.abstract.FileHandle

IConsumer implementations can mix this in to get registerProducer and unregisterProducer methods which take care of keeping track of a producer's state.

Subclasses must provide three attributes which _ConsumerMixin will read but not write: Subclasses must also override the startWriting method.
Instance VariablesproducerNone if no producer is registered, otherwise the registered producer.
producerPausedA flag indicating whether the producer is currently paused. (type: bool or int )
streamingProducerA flag indicating whether the producer was registered as a streaming (ie push) producer or not (ie a pull producer). This will determine whether the consumer may ever need to pause and resume it, or if it can merely call resumeProducing on it when buffer space is available.
streamingProducerbool or int
Method startWriting No summary
Method registerProducer Register to receive data from a producer.
Method unregisterProducer Stop consuming data from a producer, without disconnecting.
def startWriting(self): (source)
Override in a subclass to cause the reactor to monitor this selectable for write events. This will be called once in unregisterProducer if loseConnection has previously been called, so that the connection can actually close.
def registerProducer(self, producer, streaming): (source)

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.
def unregisterProducer(self): (source)
Stop consuming data from a producer, without disconnecting.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:22:34.