Implements interfaces: twisted.web.iweb.IBodyProducer

FileBodyProducer produces bytes from an input file object incrementally and writes them to a consumer.

Since file-like objects cannot be read from in an event-driven manner, FileBodyProducer uses a Cooperator instance to schedule reads from the file. This process is also paused and resumed based on notifications from the IConsumer provider being written to.

The file is closed after it has been read, or if the producer is stopped early.

Method __init__ Undocumented
Method stopProducing Permanently stop writing bytes from the file to the consumer by stopping the underlying CooperativeTask.
Method startProducing Start a cooperative task which will read bytes from the input file and write them to consumer. Return a Deferred which fires after all bytes have been written.
Method pauseProducing Temporarily suspend copying bytes from the input file to the consumer by pausing the CooperativeTask which drives that activity.
Method resumeProducing Undo the effects of a previous pauseProducing and resume copying bytes to the consumer by resuming the CooperativeTask which drives the write activity.
Instance Variable _inputFile Any file-like object, bytes read from which will be written to a consumer.
Instance Variable _cooperate A method like Cooperator.cooperate which is used to schedule all reads.
Instance Variable _readSize The number of bytes to read from _inputFile at a time.
Method _determineLength Determine how many bytes can be read out of fObj (assuming it is not modified from this point on). If the determination cannot be made, return UNKNOWN_LENGTH.
Method _writeloop Return an iterator which reads one chunk of bytes from the input file and writes them to the consumer for each time it is iterated.
_inputFile =
Any file-like object, bytes read from which will be written to a consumer.
_cooperate =
A method like Cooperator.cooperate which is used to schedule all reads.
_readSize =
The number of bytes to read from _inputFile at a time.
def __init__(self, inputFile, cooperator=task, readSize=2**16): (source)
Undocumented
def _determineLength(self, fObj): (source)

Determine how many bytes can be read out of fObj (assuming it is not modified from this point on). If the determination cannot be made, return UNKNOWN_LENGTH.

def stopProducing(self): (source)

Permanently stop writing bytes from the file to the consumer by stopping the underlying CooperativeTask.

def startProducing(self, consumer): (source)

Start a cooperative task which will read bytes from the input file and write them to consumer. Return a Deferred which fires after all bytes have been written.

ParametersconsumerAny IConsumer provider
def _writeloop(self, consumer): (source)

Return an iterator which reads one chunk of bytes from the input file and writes them to the consumer for each time it is iterated.

def pauseProducing(self): (source)

Temporarily suspend copying bytes from the input file to the consumer by pausing the CooperativeTask which drives that activity.

def resumeProducing(self): (source)

Undo the effects of a previous pauseProducing and resume copying bytes to the consumer by resuming the CooperativeTask which drives the write activity.

API Documentation for Twisted, generated by pydoctor at 2018-10-15 19:29:43.