Skip to content

FastAPI - need to asyncio.sleep() or event is not even emitted #1093

Discussion options

You must be logged in to vote

You are using a threading.Event with asyncio, which does not really make sense, since it is blocking. The ev.wait() is going to block the asyncio loop, preventing all the background activity from Socket.IO from happening (along with everything else that goes on in your application). The sleep gives you the impression that it addresses the problem only because during that 0.1 of a second the background work needed by the emit is completed. But you are still blocking the loop right after.

I don't understand why are you mixing a threading.Event in your async application. Asyncio has event objects, why not use those?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@seatedscribe
Comment options

Answer selected by seatedscribe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants