t.w.s.ProducerStream(object) : class documentation

Part of twisted.web2.stream View Source View In Hierarchy

Known subclasses: twisted.web2.http._NotifyingProducerStream

Implements interfaces: twisted.internet.interfaces.IConsumer, twisted.web2.stream.IByteStream

Turns producers into a IByteStream. Thus, implements IConsumer and IByteStream.
Method __init__ Undocumented
Method read Read some data.
Method split Split this stream into two, at byte position 'point'.
Method close Called by reader of stream when it is done reading.
Method write The producer will write data by calling this method.
Method finish Called by producer when it is done.
Method registerProducer Register to receive data from a producer.
Method unregisterProducer Stop consuming data from a producer, without disconnecting.
def __init__(self, length=None): (source)
Undocumented
def read(self): (source)

Read some data.

Returns an object conforming to the buffer interface, or if there is no more data available, returns None. Can also return a Deferred resulting in one of the above.

Errors may be indicated by exception or by a Deferred of a Failure.
def split(self, point): (source)

Split this stream into two, at byte position 'point'.

Returns a tuple of (before, after). After calling split, no other methods should be called on this stream. Doing so will have undefined behavior.

If you cannot implement split easily, you may implement it as:
   return fallbackSplit(self, point)
def close(self): (source)
Called by reader of stream when it is done reading.
def write(self, data): (source)
The producer will write data by calling this method.
def finish(self, failure=None): (source)

Called by producer when it is done.

If the optional failure argument is passed a Failure instance, the stream will return it as errback on next Deferred.
def registerProducer(self, producer, streaming): (source)

Register to receive data from a producer.

This sets self to be a consumer for a producer. When this object runs out of data (as when a send(2) call on a socket succeeds in moving the last data from a userspace buffer into a kernelspace buffer), it will ask the producer to resumeProducing().

For IPullProducer providers, resumeProducing will be called once each time data is required.

For IPushProducer providers, pauseProducing will be called whenever the write buffer fills up and resumeProducing will only be called when it empties.
Parametersproducer (type: IProducer provider )
streamingTrue if producer provides IPushProducer, False if producer provides IPullProducer. (type: bool )
ReturnsNone
RaisesRuntimeErrorIf a producer is already registered.
def unregisterProducer(self): (source)
Stop consuming data from a producer, without disconnecting.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:17:34.