[Python-ideas] [asyncio] Suggestion for a major PEP
njs at pobox.com
Sun Dec 16 04:15:57 EST 2018
If you want this style of concurrency, you don't need to write a PEP,
just 'pip install gevent' :-)
But unfortunately you're years too late to argue for making asyncio
work this way. This was discussed extensively at the time, and the
decision to use special syntax was made intentionally, and after
studying existing systems like gevent that made the other choice.
This section of the trio docs explain why explicit async/await syntax
makes life easier for developers:
It's also awkward but very doable to support both sync and async mode
with a single code base: https://github.com/python-trio/unasync/
In fact, when doing this, the async/await syntax isn't really the hard
part – the hard part is that different libraries have very different
networking APIs. E.g., the stdlib socket API and the stdlib asyncio
API are totally different.
On Sun, Dec 16, 2018 at 12:21 AM Christophe Bailly <chbailly at gmail.com> wrote:
> I copy paste the main idea from an article I have written:
> contextual async
> Imagine you have some code written for monothread. And you want to include your code in a multithread environment. Do you need to adapt all your code which is what you do when you want to migrate to async code ? The answer is no.
> Functionnally these constraints are not justified neither technically
> Do we have the tools to do this ? Yes because thanks to boost::context we can switch context between tasks. When a task suspends, it just calls a function (the event loop or reactor) to potentially switch to another task. Just like threads switch contexts…
> Async/Await logic has introduced a symetric relation wich introduces unnecessary contraints. We should just the same logic as thread logic.
> Read the examples in the article I have developped a prototype in C++ and everything works perfectly.
> My opinion is that sooner or later, it will have to switch to this logic because chaining async/aswait is a huge contraints and does not make sense in my opinion.
> Maybe I am missing something,
> Feel free to give me your feedback.
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
Nathaniel J. Smith -- https://vorpus.org
More information about the Python-ideas