def func(request): app = request.app resp = EventSourceResponse() yield from resp.prepare(request) resp.send('foo', event='bar', id='xyz', retry=1) app['socket'].append(resp) yield from resp.wait() return resp
def func(request): resp = EventSourceResponse() yield from resp.prepare(request) with pytest.raises(TypeError): resp.send('foo', retry='one') resp.send('foo', retry=1) resp.stop_streaming() yield from resp.wait() return resp
def func(request): app = request.app resp = EventSourceResponse() resp.ping_interval = 1 yield from resp.prepare(request) resp.send('foo') app['socket'].append(resp) yield from resp.wait() return resp
def func(request): if with_sse_response: resp = yield from sse_response(request, headers={'X-SSE': 'aiohttp_sse'}) else: resp = EventSourceResponse(headers={'X-SSE': 'aiohttp_sse'}) yield from resp.prepare(request) resp.send('foo') resp.send('foo', event='bar') resp.send('foo', event='bar', id='xyz') resp.send('foo', event='bar', id='xyz', retry=1) resp.stop_streaming() yield from resp.wait() return resp