I have a python generator that yields parts of a file (a wsgi app_iter
) and I need to pass it to an interface that expects it to have the classical read
and readlines
methods (I want to pass it as wsgi.input
of another Request
).
Is is possible to do it in a way that does not materialize the whole generator content into memory? The idea is to wrap the generator in something that has read
and readline
(such as BytesIO
or StringIO
) and do it in a lazy fashion.