[Tutor] asyncio or threading

Zachary Ware zachary.ware+pytut at gmail.com
Sun Feb 28 02:24:59 EST 2016


My apologies for taking so long to reply here again, it's been a busy
couple of weeks.

On Mon, Feb 15, 2016 at 7:18 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> On 15/02/16 21:08, Zachary Ware wrote:
>> This is not all asyncio can do. Callbacks are only one way of using it, the
>> other, more common method is to use coroutines such that most of your code
>> reads almost like regular, synchronous code.
>
> I'm not sure about "most common" since every single example of
> asyncio I've seen so far has used callbacks not coroutines.
> (Not that I've seen too many examples, but the ones I have seen
> all used callbacks.)

Could you point me towards some of those examples?

>> I don't think this is quite true either; I've heard the JavaScript
>> equivalent referred to frequently as "callback hell",
>
> A slanderous comment that's not really deserved :-)

Sorry; my information on this point is all secondhand (or worse) as
I've not used NodeJS and have somehow even avoided JavaScript as a
whole.  Take anything I say about JavaScript/NodeJS with a healthy
measure of salt :).  My impression was that the callback style
naturally leads to doing things where callbacks are chained several
layers deep, which makes things hard to read and takes concentrated
effort (slight though it may be) to avoid.

> As a matter of interest which tutorials on asyncio cover this best?
> I've only read one closely and it was all about callbacks but
> it impressed me enough to become an asyncio fan. However I'm
> certainly interested in finding out more on the coroutine front.

Frankly, I have yet to see a *good* asyncio tutorial, but haven't
looked very hard either.  I learned how to use it from the reference
docs (which are also somewhat lacking still, I had to fix some issues
in the docs as I was learning it) and trial-and-error, which actually
worked surprisingly well.

-- 
Zach


More information about the Tutor mailing list