[Python-ideas] Preemptive multitasking and asyncio

Chris Angelico rosuav at gmail.com
Wed Jan 24 11:59:07 EST 2018

On Thu, Jan 25, 2018 at 3:46 AM, Thomas Güttler
<guettliml at thomas-guettler.de> wrote:
> I found a question and answer at Stackoverflow[1] which says
> that asyncio/await is like cooperative multitasking.

"Like"? It *is* a form of co-operative multitasking.

> My whish is to have preemptive multitasking: The interpreter
> does the yielding. The software developer does not need to
> insert async/await keywords into its source code any more.

The time machine strikes again!

Sounds like you want threads. Check out the threading module, but be
aware that many Python interpreters, including CPython (the most
commonly-used Python), have restrictions on when threads can switch
contexts. Chances are it'll work for you, but if it can't, you may
want to consider the multiprocessing module instead.


More information about the Python-ideas mailing list