Part of twisted.internet.abstract View Source View In Hierarchy
IConsumerimplementations can mix this in to get
unregisterProducermethods which take care of keeping track of a producer's state.
Subclasses must provide three attributes which
will read but not write:
Trueas long as the consumer has someplace to send bytes (for example, a TCP connection), and then
Falsewhen it no longer does.
Falseuntil something like
ITransport.loseConnectionis called, indicating that the send buffer should be flushed and the connection lost afterwards. Afterwards,
Falseuntil the consumer no longer has a place to send bytes, then
Subclasses must also override the
|Instance Variable||producerPaused||A flag indicating whether the producer is currently paused. (type:
|Instance Variable||streamingProducer 0||A 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
|Method||registerProducer||Register to receive data from a producer.|
|Method||unregisterProducer||Stop consuming data from a producer, without disconnecting.|
resumeProducingon it when buffer space is available.
loseConnectionhas previously been called, so that the connection can actually close.
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.