I'm debugging a FastAPI application, and I have a problem similar to what's been mentioned in this post: a call to asyncio.wait_for that should time out doesn't:
try:
    await wait_for(completion_event.wait(), 1.0)
except TimeoutError:
    logging.info("timeout")
    return SubmissionResult(post_id=post_id, language_check_pending=True)
This snippet is a part of a FastAPI's POST request handler. Here, completion_event is an asyncio.Event object. I can put a breakpoint on the line with wait_for, watch it get stuck for much more than 1s, and then move right past the except block. There's no doubt that wait_for doesn't do what it's expected to do.
I have no idea why it behaves like that. At this point, I'm starting to suspect the FastAPI's internals, since it uses uvloop as a "faster drop-in replacement for asyncio". But I don't know how to test this assumption, much less to fix this problem if it's indeed the case.
Any suggestions?
 
     
     
    