Hi Chris,

I don't know your technical or efficiency constraints, however, if you want
to be 100% sure that you won't have any side effects between sync and async
code, you might have two daemons, one for each pattern, and use
microservice approach to exchanges messages.
Especially if you plan to use WebSockets, it would help you.
Up to you to decide the easiest approach for you.

Regards.

--
Ludovic Gasc (GMLudo)
Lead Developer Architect at ALLOcloud
https://be.linkedin.com/in/ludovicgasc

2017-07-10 5:48 GMT+02:00 Chris Jerdonek <chris.jerdo...@gmail.com>:

> 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
> _______________________________________________
> Async-sig mailing list
> Async-sig@python.org
> https://mail.python.org/mailman/listinfo/async-sig
> Code of Conduct: https://www.python.org/psf/codeofconduct/
>
_______________________________________________
Async-sig mailing list
Async-sig@python.org
https://mail.python.org/mailman/listinfo/async-sig
Code of Conduct: https://www.python.org/psf/codeofconduct/

Reply via email to