RuntimeError: this event loop is already running #194
Closed
foarsitter
started this conversation in
General
Replies: 1 comment 1 reply
-
@foarsitter the fact you got it working on gunicorn is just because it doesn't rely on asyncio event loop. Granian on the other hand uses asyncio even in WSGI protocol (just to preserve the same instances tbh) and thus the event loop is already running. Just a small OT consideration: running sync code through asyncio is quite inefficient: I personally would consider switching to async flow and ASGI completely if feasible. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Got enthusiastic about this yet another rust replacement (
yarr
) when I heard about it. I like where the Python landscape is heading to.Replaced
gunicorn
withgranian
and everything went smooth, so great job!Some third party library forced me in using asyncio since they stopped supporting the sync version. Using
asyncio.get_event_loop()
andloop.run_until_complete
let me run there async function in my wsgi application.After adopting
granian
I experienced the following error.I can reproduced the error with the following flask snippet. localhost:8000/loop errors, while localhost:8000/lasyncio and localhost:8000/asgiref are succeeding where the later is the best approach I think.
My question is if I just was lucky that my
run_until_complete
version worked with gunicorn or that it is something that should work out of the box with granian?Beta Was this translation helpful? Give feedback.
All reactions