Bug - Unittest indefinitely hangs when using BaseHTTPMiddleware, sync router and quit(). Needs MainThread _daemonic hack. #2537
Unanswered
arrman-saha
asked this question in
Potential Issue
Replies: 1 comment
-
Hi, looks like anyio worker threads were getting stuck because BaseException was not handled in BaseHTTPMiddleware. Can I open a PR for this ? (The ask account is different because I accidentally started discussion from my work account. I'm not trying to spam the discussions with an alt or anything.) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When a BaseHTTPMiddleware is used, and we want to quit the application in the router everything works as expected when deploying the app. However unit testcases permanently hang if we use a sync router. To make the testcases not hang we need a hack -
setattr(threading.main_thread(), "_daemonic", True)
. But this hack is not needed for async router.I've tried looking for similar issues but can't find something similar.
I originally thought this was a fastapi issue, but seems like this is a starlette issue.
The following code will hang indefinitely after testcases have passed, unless either the
async def
part is used orsetattr
part is used.Beta Was this translation helpful? Give feedback.
All reactions