Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-25 Thread Mark E. Haase
Explicit yield points makes reasoning about multitasking much easier. The author of Twisted wrote an excellent post about this.[1] I agree that the Python documentation doesn't do justice to the question, "when should I use asyncio instead of threads?" [1]

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Thomas Güttler
Am 24.01.2018 um 17:59 schrieb Steven D'Aprano: On Wed, Jan 24, 2018 at 05:46:29PM +0100, Thomas Güttler wrote: I found a question and answer at Stackoverflow[1] which says that asyncio/await is like cooperative multitasking. My whish is to have preemptive multitasking: The interpreter does

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Nick Timkovich
If I'm understanding correctly, the interpreter already does this with threads. About every 15 milliseconds the interpreter will stop a thread and see if there are any others to work on, see "Grok the GIL," blog: https://emptysqua.re/blog/grok-the-gil-fast-thread-safe-python/ or the PyCon talk:

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Steven D'Aprano
On Wed, Jan 24, 2018 at 05:46:29PM +0100, Thomas Güttler wrote: > I found a question and answer at Stackoverflow[1] which says > that asyncio/await is like cooperative multitasking. > > My whish is to have preemptive multitasking: The interpreter > does the yielding. Isn't that what threading

Re: [Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Chris Angelico
On Thu, Jan 25, 2018 at 3:46 AM, Thomas Güttler 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

[Python-ideas] Preemptive multitasking and asyncio

2018-01-24 Thread Thomas Güttler
I found a question and answer at Stackoverflow[1] which says that asyncio/await is like cooperative 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.