Asynchronous programming

Marko Rauhamaa marko at pacujo.net
Thu Aug 11 10:35:11 EDT 2016


Steven D'Aprano <steve+python at pearwood.info>:

> Say I want to download data from a network, and it will take a long
> time. If I can do the read in parallel to something else, that makes
> sense:
>
>   begin downloading in another thread/process
>   make a coffee
>   process download
>
> But what's the point in doing it asynchronously if I have to just wait for
> it to complete?

You can do many things concurrently, as the philosophers in my previous
example.

You will need two asyncs, one for downloading, another one for making
coffee, just like you would with threads. Then, run both asyncs
concurrently with asyncio.wait().


Marko



More information about the Python-list mailing list