
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. AFAIK the erlang interpreter does something like this. I guess it is impossible to implement this, but it was somehow important for me to speak out my which. What do you think? Regards, Thomas Güttler [1] https://stackoverflow.com/questions/38865050/is-await-in-python3-cooperative... -- Thomas Guettler http://www.thomas-guettler.de/ I am looking for feedback: https://github.com/guettli/programming-guidelines

Am 24.01.2018 um 17:59 schrieb Steven D'Aprano:
Hmmm, yes, you are right. I guess I have not understood something up to now. If async/await is the answer. What was the question? AFAIK it can help to solve the c10k problem. If I don't have the c10k problem, then what is the benefit of async/await? If it is only about IO, there are python bindings for libraries like libuv. I guess this whole topic is too ...(I am missing the right term here)... for average developers like me. Regards, Thomas Güttler -- Thomas Guettler http://www.thomas-guettler.de/ I am looking for feedback: https://github.com/guettli/programming-guidelines

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] https://glyph.twistedmatrix.com/2014/02/unyielding.html On Thu, Jan 25, 2018 at 2:37 AM, Thomas Güttler < guettliml@thomas-guettler.de> wrote:

On Thu, Jan 25, 2018 at 3:46 AM, Thomas Güttler <guettliml@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.
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. ChrisA

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: https://www.youtube.com/watch?time_continue=150&v=7SSYhuk5hmc On Wed, Jan 24, 2018 at 10:46 AM, Thomas Güttler < guettliml@thomas-guettler.de> wrote:

Am 24.01.2018 um 17:59 schrieb Steven D'Aprano:
Hmmm, yes, you are right. I guess I have not understood something up to now. If async/await is the answer. What was the question? AFAIK it can help to solve the c10k problem. If I don't have the c10k problem, then what is the benefit of async/await? If it is only about IO, there are python bindings for libraries like libuv. I guess this whole topic is too ...(I am missing the right term here)... for average developers like me. Regards, Thomas Güttler -- Thomas Guettler http://www.thomas-guettler.de/ I am looking for feedback: https://github.com/guettli/programming-guidelines

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] https://glyph.twistedmatrix.com/2014/02/unyielding.html On Thu, Jan 25, 2018 at 2:37 AM, Thomas Güttler < guettliml@thomas-guettler.de> wrote:

On Thu, Jan 25, 2018 at 3:46 AM, Thomas Güttler <guettliml@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.
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. ChrisA

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: https://www.youtube.com/watch?time_continue=150&v=7SSYhuk5hmc On Wed, Jan 24, 2018 at 10:46 AM, Thomas Güttler < guettliml@thomas-guettler.de> wrote:
participants (5)
-
Chris Angelico
-
Mark E. Haase
-
Nick Timkovich
-
Steven D'Aprano
-
Thomas Güttler