Go to the latest version of this document.

# ``twisted`.`web`.`wsgi`.`_WSGIResponse``

class documentation

`class _WSGIResponse: (source)`

Constructor: `_WSGIResponse(reactor, threadpool, application, request)`

View In Hierarchy

Helper for `WSGIResource` which drives the WSGI application using a threadpool and hooks it up to the `http.Request`.

Method | `__init__` | Undocumented
Method | `run` | Call the WSGI application object, iterate it, and handle its output.
Method | `start` | Start the WSGI application in the threadpool.
Method | `startResponse` | The WSGI start_response callable. The given values are saved until they are needed to generate the response.
Method | `write` | The WSGI write callable returned by the start_response callable. The given bytes will be written to the response body, possibly flushing the status and headers first.
Instance Variable | `application` | The WSGI application object.
Instance Variable | `environ` | The WSGI environment `dict`.
Instance Variable | `headers` | A list of HTTP response headers supplied to the WSGI start_response callable by the application.
Instance Variable | `reactor` | An `IReactorThreads` provider which is used to call methods on the request in the I/O thread.
Instance Variable | `request` | The `http.Request` upon which the WSGI environment is based and to which the application's output will be sent.
Instance Variable | `started` | A `bool` indicating whether or not the response status and headers have been written to the request yet. This may only be read or written in the WSGI application thread.
Instance Variable | `status` | The HTTP response status `str` supplied to the WSGI start_response callable by the application.
Instance Variable | `threadpool` | A `ThreadPool` which is used to call the WSGI application object in a non-I/O thread.
Method | `_finished` | Record the end of the response generation for the request being serviced.
Method | `_sendResponseHeaders` | Set the response code and response headers on the request object, but do not flush them. The caller is responsible for doing a write in order for anything to actually be written out in response to the request.
Class Variable | `_log` | Undocumented
Instance Variable | `_requestFinished` | A flag which indicates whether it is possible to generate more response data or not. This is `False` until `http.Request.notifyFinish` tells us the request is done, then `True`.

def __init__(self, reactor, threadpool, application, request): (source)

Undocumented

def run(self): (source)

Call the WSGI application object, iterate it, and handle its output.

This must be called in a non-I/O thread (ie, a WSGI application thread).

def start(self): (source)

Start the WSGI application in the threadpool.

This must be called in the I/O thread.

def startResponse(self, status, headers, excInfo=None): (source)

The WSGI start_response callable. The given values are saved until they are needed to generate the response.

This will be called in a non-I/O thread.

def write(self, data): (source)

The WSGI write callable returned by the start_response callable. The given bytes will be written to the response body, possibly flushing the status and headers first.

This will be called in a non-I/O thread.

application = (source)

The WSGI application object.

environ = (source)

The WSGI environment `dict`.

headers = (source)

A list of HTTP response headers supplied to the WSGI start_response callable by the application.

reactor = (source)

An `IReactorThreads` provider which is used to call methods on the request in the I/O thread.

request = (source)

The `http.Request` upon which the WSGI environment is based and to which the application's output will be sent.

started: `bool` = (source)

A `bool` indicating whether or not the response status and headers have been written to the request yet. This may only be read or written in the WSGI application thread.

status = (source)

The HTTP response status `str` supplied to the WSGI start_response callable by the application.

threadpool = (source)

A `ThreadPool` which is used to call the WSGI application object in a non-I/O thread.

def _finished(self, ignored): (source)

Record the end of the response generation for the request being serviced.

def _sendResponseHeaders(self): (source)

Set the response code and response headers on the request object, but do not flush them. The caller is responsible for doing a write in order for anything to actually be written out in response to the request.

This must be called in the I/O thread.

_log = (source)

Undocumented

_requestFinished: `bool` = (source)

A flag which indicates whether it is possible to generate more response data or not. This is `False` until `http.Request.notifyFinish` tells us the request is done, then `True`.