-
using flask, I was receiving "no event loop" errors. So I decided to migrate my app from flask for the async support. The idea was to run everything under the same Async Event loop, but now I see a different error when trying to do this: "Event Loop already running", and I've literally tried everything (details available, but they include passing loop = loop), so here I am: Let me make the description simple:
Receive Error -> "This event loop is already running" Currently, I can see class B event loop running fine -> async tasks running periodically printing to log (connection is established OK). Quart App C is also running fine, except: when hitting views that require a call to self.b_instance.method() Entire thing starts from : asyncio.run(classA.run()) My original idea was to run everything in a main event loop so that of course everything was under the same "event loop", await async sleep to return control to event loop so other tasks could run, including Quart WebServer. I tried HyperCorn serve: self._quart_server_task = asyncio.create_task(serve(self.quart_server.app, config)) Among various other things, like loop.get_running_event_loop, etc. etc. etc. I will nevertheless admit that I'm an async newb, and a Quart newb as well. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I don't think this other library should be using a loop to run asyncio.sleep()... we shall see what the maintainer thinks, for now, thank you all. For posterity, if you ever get stuck with something like this, printing the event loop id and thread id in numerous places in your code can help identify whether the thread and event loop are the same or not. |
Beta Was this translation helpful? Give feedback.
I don't think this other library should be using a …