Open dwarfcrank opened 2 months ago
Yes, this is kinda a duplicate of #323, at least the root cause is the same.
Given the README states:
Due to the nature of such handlers some libraries and specific application code relying on asyncio internals might not work.
I will just keep this open for knowledge and add the wontfix
label until I figure out what to do with --opt
in the future.
773f99790e66b4865529da353a270052b7020a42
I've managed to reproduce this on Ubuntu with Python 3.10 and an older Granian version as well, so not sure if the above version info is really relevant, just included for good measure.
The issue is that with
--opt
, if you run and await a coroutine withasyncio.create_task()
, any exceptions raised in the task can't be caught from the outside.Repro case
repro.py
:When running the app without
--opt
, we get the expected response:But the same request with
--opt
enabled results in this:And the custom error response is not returned:
While writing this issue, I noticed that if I move the whole
try ... except
block inside the function that's wrapped in a task everything works as expected, so this seems to be less of an issue than I originally thought.Anyway, this issue seems somewhat related to #323, so if you still feel like just dropping
--opt
in the future feel free to close this aswontfix
😅