[Async-sig] using asyncio in synchronous applications
Chris Jerdonek
chris.jerdonek at gmail.com
Sun Jul 9 23:48:41 EDT 2017
I have a two-part question.
If my application is single-threaded and synchronous (e.g. a web app
using Gunicorn with sync workers [1]), and occasionally I need to call
functions in a library that requires an event loop, is there any
downside to creating and closing the loop on-the-fly only when I call
the function? In other words, is creating and destroying loops cheap?
Second, if I were to switch to a multi-threaded model (e.g. Gunicorn
with async workers), is my only option to start the loop at the
beginning of the process, and use loop.call_soon_threadsafe()? Or can
I do what I was asking about above and create and close loops
on-the-fly in different threads? Is either approach much more
efficient than the other?
Thanks,
--Chris
[1] http://docs.gunicorn.org/en/latest/design.html#sync-workers
More information about the Async-sig
mailing list