Stream & Multipart
1. Generator
def gen():
yield 1
yield 2
yield 3>>> x = gen()
>>> x
<generator object gen at 0x7f06f3059c30>
>>> next(x) // python3
1
>>> next(x)
2
>>> next(x)
3
>>> next(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration2. Multipart
Implement in-place updates = _multipart _response.
Multipart responses
a header includes one of the multipart content types
parts, separated by a _boundary _marker
3. Video Streaming Server = generator + multipart
4. Limitation
Regular request: [1]web worker receives a request, [2]invoke handler, [3]return response, [4]the worker is free, and is available for another request.
Stream request: A worker will stay locked to the client until the client disconnects.
Last updated
Was this helpful?