Hello,

On Wed, 12 Nov 2014 01:09:41 +0100
Victor Stinner <[email protected]> wrote:

> Hi,
> 
> 2014-11-05 18:17 GMT+01:00 Paul Sokolovsky <[email protected]>:
> > I'm author of alternative implementation of asyncio subset for
> > MicroPython,
> 
> Oh, interesting. Where can I find your project? Is it fully compatible
> with asyncio?

It's here:
https://github.com/micropython/micropython-lib/tree/master/uasyncio.core
https://github.com/micropython/micropython-lib/tree/master/uasyncio

Core event loop and subclass implementing async I/O support using
select.poll()-like implementation.

It implements only subset of asyncio functionality, generally the aim
was to make the minimal possible implementation of coroutine
scheduling and async socket I/O which asyncio-like interface.

The biggest aim I'd dream to achieve is that uasyncio code was runnable
on asyncio as is (without compromising efficiency on uasyncio side),
there's no talk about the opposite direction.   

> 
> > my surprise, founds that
> > there's now BaseEventLoop.create_task(coro) method
> > (https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.BaseEventLoop.create_task)
> > to schedule them in obvious and direct method directly against an
> > event loop.
> > Thank you very much for this addition! (...)
> 
> FYI I added this method for the greenio project, to support other
> implementation of event loops.
> 
> I would like to replace all direct calls to Task with create_task, but
> I had some issues in the documentation. For Python 3.4 documentation,
> Task constructor may be preferred because create_task is only
> available since Python 3.4.2 :-/

Well, I'm at least glad to see asyncio evolve to accommodate new
usecases, and not being set in stone. In that regard, now that
BaseEventLoop with .create_task() already acquired knowledge about
existence of native Python generators (which previously was layered
away in Task class), do you think that it might be possible to go step
further and allow scheduling a new coroutine by just yielding a
generator instance? In other words:


=======
def task1():
    yield from [1, 2, 3]


# in some other coroutine
def task2():
    ...
    yield task1()
    ...
=======

The idea is certainly not mine, I saw it in David Beazley's
presentations, http://www.dabeaz.com/generators/ , and possibly in some
other pre-asyncio coroutine frameworks. This scheduling form looks
pretty natural and intuitive. Yield can of course return some handle
(Task instance in case of asyncio) to allow to synchronize with started
coroutine.

> 
> Victor



-- 
Best regards,
 Paul                          mailto:[email protected]

Reply via email to