sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
505 stars 36 forks source link

RuntimeError in stream_generator.py example #49

Closed DurandA closed 1 year ago

DurandA commented 1 year ago

While further investigating on https://github.com/sysid/sse-starlette/issues/48, I tried to run the stream_generator example as I expected it to exhibit the same behavior.

First, I had to fix a queue declaration:

- self._queue = asyncio.Queue[ServerSentEvent]()
+ self._queue: asyncio.Queue[ServerSentEvent] = asyncio.Queue()

Then, issuing a GET /sse throws the following error:

RuntimeError: Task <Task pending name='sse_starlette.sse.EventSourceResponse.__call__.<locals>.wrap' coro=<EventSourceResponse.__call__.<locals>.wrap() running at /home/duranda/devel/fastapi-example/venv/lib/python3.8/site-packages/sse_starlette/sse.py:230> cb=[TaskGroup._spawn.<locals>.task_done() at /home/duranda/devel/fastapi-example/venv/lib/python3.8/site-packages/anyio/_backends/_asyncio.py:726]> got Future <Future pending> attached to a different loop
sysid commented 1 year ago

For me the example is running correct, just checked again. I do not think this is an sse-starlette related issue, still.

Happy to investigate further if you provided an example for reproduction.