class documentation

class ClosingIterator:

View In Hierarchy

The WSGI specification requires that all middlewares and gateways respect the close callback of the iterable returned by the application. Because it is useful to add another close action to a returned iterable and adding a custom iterable is a boring task this class can be used for that:

return ClosingIterator(app(environ, start_response), [cleanup_session,
                                                      cleanup_locals])

If there is just one close function it can be passed instead of the list.

A closing iterator is not needed if the application uses response objects and finishes the processing if the response is started:

try:
    return response(environ, start_response)
finally:
    cleanup_session()
    cleanup_locals()
Method __init__ Undocumented
Method __iter__ Undocumented
Method __next__ Undocumented
Method close Undocumented
Instance Variable ​_callbacks Undocumented
Instance Variable ​_next Undocumented
def __init__(self, iterable, callbacks=None):

Undocumented

Parameters
iterable:t.Iterable[bytes]Undocumented
callbacks:t.Optional[t.Union[t.Callable[[], None], t.Iterable[t.Callable[[], None]]]]Undocumented
def __iter__(self):

Undocumented

Returns
ClosingIteratorUndocumented
def __next__(self):

Undocumented

Returns
bytesUndocumented
def close(self):

Undocumented

_callbacks =

Undocumented

_next =

Undocumented