Asyncio -- delayed calculation

Chris Angelico rosuav at gmail.com
Mon Nov 28 23:37:22 EST 2016


On Tue, Nov 29, 2016 at 3:16 PM, Gregory Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> "await" means "don't continue this function until that's done". It
>> blocks the function until a non-blocking operation is done.
>
>
> However, *not* using 'await' doesn't mean the operation
> will be done without blocking. Rather, it won't be done
> at all (and is usually an error, but there's no way for
> the implementation to detect it at the time).
>
> I don't blame Steve for being confused. All the
> terminology around async/await is inherently confusing
> and counterintuitive, IMO. I'm disappointed that we've
> ended up here.

Asynchronous I/O is something to get your head around. As someone who
teaches both JavaScript and Python, I've run into this quite a bit,
and frankly, callbacks may be easy to explain at a concrete level, but
I'd much rather work with generator-based async functions (which JS is
getting soon too). The best way to think about it IMO is a "process"
that does blocking calls, and which the "system" can multitask away
from any time it's blocked. Your function awaits something, but Python
doesn't.

ChrisA



More information about the Python-list mailing list