Not sure if this is expected/by-design or not, so I'm reporting it:
import asyncio
async def app(scope, proto):
async with asyncio.timeout(1):
await asyncio.sleep(0.1)
proto.response_str(
status=200,
headers=[
('content-type', 'text/plain')
],
body=f"Hello, world!"
)
$ granian --opt --interface rsgi main:app
[ERROR] Application callable raised an exception
Traceback (most recent call last):
File "main.py", line 5, in app
async with asyncio.timeout(1):
File "/usr/lib/python3.11/asyncio/timeouts.py", line 90, in __aenter__
raise RuntimeError("Timeout should be used inside a task")
RuntimeError: Timeout should be used inside a task
This was quite difficult to track down, maybe a small section could be added to the documentation with a short list of what's known to not work when using --opt
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too