M
Size: a a a
M
KL
DB
DB
M
M
M
NK
NK
N
S
MV
SS
OT
SB
PR
Д
Д
def gen(start, finish):
while start < finish:
yield str(start * 0.33)
sleep(1)
start += 1
async def stream_testgen(request):
loop = asyncio.get_event_loop()
is_first = True
with ThreadPoolExecutor() as pool:
for line in await loop.run_in_executor(pool, gen, 1, 5):
data, content_type = formatter(line)
if is_first:
stream = web.StreamResponse(status=200, reason="OK", headers={"Content-Type": content_type})
await stream.prepare(request)
is_first = False
await stream.write(data)
await stream.drain()
return stream
AK
Д