Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`web`.`client`.`FileBodyProducer``

class documentation

`class FileBodyProducer: (source)`

Constructor: `FileBodyProducer(inputFile, cooperator, readSize)`

Implements interfaces: `twisted.web.iweb.IBodyProducer`

View In Hierarchy

`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 | `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.
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. If this `Deferred` is cancelled before it is fired, stop reading and writing bytes.
Method | `stopProducing` | Permanently stop writing bytes from the file to the consumer by stopping the underlying `CooperativeTask`.
Instance Variable | `length` | `length` is a `int` indicating how many bytes in total this `IBodyProducer` will write to the consumer or `UNKNOWN_LENGTH` if this is not known in advance.
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.
Instance Variable | `_cooperate` | A method like `Cooperator.cooperate` which is used to schedule all reads.
Instance Variable | `_inputFile` | Any file-like object, bytes read from which will be written to a consumer.
Instance Variable | `_readSize` | The number of bytes to read from `_inputFile` at a time.
Instance Variable | `_task` | Undocumented

def __init__(self, inputFile, cooperator=task, readSize=2**16): (source)

Undocumented

def pauseProducing(self): (source)
from `twisted.internet.interfaces.IPushProducer`

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

def resumeProducing(self): (source)
from `twisted.internet.interfaces.IPushProducer`

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

def startProducing(self, consumer): (source)
from `twisted.web.iweb.IBodyProducer`

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. If this `Deferred` is cancelled before it is fired, stop reading and writing bytes.

Parameters
consumer | Any `IConsumer` provider

def stopProducing(self): (source)
from `twisted.web.iweb.IBodyProducer`

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

length = (source)
from `twisted.web.iweb.IBodyProducer`

`length` is a `int` indicating how many bytes in total this `IBodyProducer` will write to the consumer or `UNKNOWN_LENGTH` if this is not known in advance.

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

_cooperate = (source)

A method like `Cooperator.cooperate` which is used to schedule all reads.

_inputFile = (source)

Any file-like object, bytes read from which will be written to a consumer.

_readSize = (source)

The number of bytes to read from `_inputFile` at a time.

_task = (source)

Undocumented