[Python-Dev] Minimal async event loop and async utilities (Was: PEP 492: async/await in Python; version 4)

Paul Sokolovsky pmiscml at gmail.com
Wed May 6 12:03:37 CEST 2015


Hello,

On Wed, 6 May 2015 09:27:16 +0100
Paul Moore <p.f.moore at gmail.com> wrote:

> On 6 May 2015 at 07:46, Greg Ewing <greg.ewing at canterbury.ac.nz>
> wrote:
> > Another problem with the "core" idea is that
> > you can't start with an event loop that "just does
> > scheduling" and then add on other features such
> > as I/O *from the outside*. There has to be some
> > point at which everything comes together, which
> > means choosing something like select() or
> > poll() or I/O completion queues, and build that
> > into the heart of your event loop. At that point
> > it's no longer something with a simple core.

[]

> So, to some extent (how far is something I'd need to code up a loop to
> confirm) you can build the Futures and synchronisation mechanisms with
> an event loop that supports only this "minimal interface".
> 
> Essentially, that's my goal - to allow people who want to write (say)
> a Windows GUI event loop, or a Windows event loop based of
> WaitForXXXObject, or a Tkinter loop, or whatever, to *not* have to
> write their own implementation of synchronisation or future objects.
> 
> That may mean lifting the asyncio code and putting it into a separate
> library, to make the separation between "asyncio-dependent" and
> "general async" clearer. Or if asyncio's provisional status doesn't
> last long enough to do that, we may end up with an asyncio
> implementation and a separate (possibly 3rd party) "general"
> implementation.

MicroPython has alternative implementation of asyncio subset. It's
structured as a generic scheduler component "uasyncio.core"
https://github.com/micropython/micropython-lib/blob/master/uasyncio.core/uasyncio/core.py
(170 total lines) and "uasyncio" which adds I/O scheduling on top of
it:
https://github.com/micropython/micropython-lib/blob/master/uasyncio/uasyncio/__init__.py

"uasyncio.core" can be used separately, and is intended for usage as
such on e.g. microcontrollers. It's built around native Python concept
of coroutines (plus callbacks). It doesn't include concept of futures.
They can be added as an extension built on top, but so far I didn't see
need for that, while having developed a web picoframework 
for uasyncio (https://github.com/pfalcon/picoweb)


-- 
Best regards,
 Paul                          mailto:pmiscml at gmail.com


More information about the Python-Dev mailing list