[Python-ideas] Concurrency HOWTO for Python (was: Concurrency Modules)

Ben Finney ben+python at benfinney.id.au
Sat Jul 11 05:10:39 CEST 2015


Steve Dower <Steve.Dower at microsoft.com>
writes:

> I'm going to dive into an analogy here. Hopefully it holds up better
> than most...
> […]
>
> * You can do a synchronous wait, by sitting and staring at the oven
>   until it's done.
>
> * You can poll, by occasionally interrupting yourself to walk over to
>   the oven and see if it's done yet.
>
> * You can use a signal/interrupt, where the oven is going to make some
>   noise and interrupt you when you're ready (but note: you know that the
>   oven is done without having to walk over and check it).
>
> * Or you can use asyncio, where you occasionally interrupt yourself
>   and, when you do, the oven will make some noise if it has finished.
>   (and if you never interrupt yourself, the oven never makes a sound)
>
[…]

> Hopefully that helps clear things up for some people. No example is
> perfect for everyone, ultimately, so the more we put out there the
> more likely

Thank you, Steve! That is the clearest explanation of different
concurrency models I've ever read. I now feel I have a firm
understanding of how they're different and their relative merits.

I hope that analogy can be worked into a putative “Concurrency HOWTO” at
<URL:https://docs.python.org/3/howto/>.

-- 
 \       “If consumers even know there's a DRM, what it is, and how it |
  `\     works, we've already failed.” —Peter Lee, Disney corporation, |
_o__)                                                             2005 |
Ben Finney



More information about the Python-ideas mailing list