This is continuation of the discussion from #286 (comment)
Hello! I experience an issue when running Litestar with Granian that I do not have when use Uvicorn. In the previous discussion I don't think I've provided a sufficient illustration.
Here’s a new one:
import asyncio
import math
import typing
import litestar
from litestar.response import ServerSentEvent
async def iter_sse_data() -> typing.AsyncIterable[str]:
yield "hi"
try:
print("about to sleep indefinitely")
await asyncio.sleep(math.inf)
finally:
print("cleaned up")
@litestar.get("/")
async def root() -> ServerSentEvent:
return ServerSentEvent(iter_sse_data())
app = litestar.Litestar([root])
- Run the app with Granian.
- Run
curl http://localhost:8000/, wait for data: hi and press Ctrl+C.
- See that logs do not contain
cleaned up.
Run the app with Uvicorn—and you’ll see that cleaned up was printed.