Asynchronous processing is more efficient -- surely not?

Chris Angelico rosuav at
Wed Apr 4 12:47:12 EDT 2018

On Thu, Apr 5, 2018 at 1:48 AM, Julien Salort <listes at> wrote:
> Le 04/04/2018 à 14:45, Chris Angelico a écrit :
>> How do you use run_in_executor to turn this asynchronous, and how
>> would this compare to creating one thread for each camera?
> This is exactely like creating a thread. Except that I have to do so only
> for blocking calls and without having to bother myself with threads or
> thread pools.
> It is just that it looks very simple to me. But I have never really done any
> asynchronous programming before. So, maybe using threads is just as simple,
> I don't know. What I find nice with asyncio is that it integrates easily
> with already written Python code, i.e. converting synchronous code to
> asynchronous code is relatively straightforward. Again, my problem is that
> it leads to code duplication. But that probably means that I should separate
> the logic into separate functions more.

Okay, that's fair. So you're basically using asyncio as a means of
managing threads, without actually using threads. I do recommend
looking into the threading module and getting a feel for actual
threaded programming, but if you don't, so be it.

In any case, asyncio is functioning as a wrapper around a thread pool;
so it's never going to be more efficient or more effective than an
actual thread pool, but might be easier to work with in your code.


More information about the Python-list mailing list