[Python-ideas] Are there asynchronous generators?

Nick Coghlan ncoghlan at gmail.com
Thu Jul 2 14:15:35 CEST 2015


On 2 July 2015 at 19:57, Paul Moore <p.f.moore at gmail.com> wrote:
> So while I agree that if you don't need an event driven model, it can
> seem like pointless complexity, I *also* think that the pure callback
> approach to event driven code is what feels "obvious" to most people.
> It's maybe not the easiest model to code with, but it is the easiest
> one to think about - and mentally making the link between callbacks
> and async/await isn't straightforward. So even though people can
> understand event-driven problems, they can't, without experience, see
> how async/await *addresses* that problem.

If an operation doesn't need to wait for IO itself, then it can
respond immediately using a normal callback (just as a generator is
useful for implementing iterators, but would be pointless for a normal
function call).

async/await is more useful for multi-step processes, and for
persistent monitoring of a data source in an infinite loop (e.g.
listening for push notifications from a server process).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list