[Tutor] asyncio or threading
alan.gauld at btinternet.com
Mon Feb 15 20:18:17 EST 2016
On 15/02/16 21:08, Zachary Ware wrote:
> This isn't quite accurate. asyncio only uses threading if you explicitly
> tell it to use a thread for something, otherwise everything is run in
> coroutines in the main thread,
Thanks for that, my asyncio tutorial was obviously seriously
one sided, it made no mention of coroutines but did promise
threading. But thanks to your reply I've now discovered Python
coroutines. Something I had completely missed until now.
> 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.)
>> you are likely to find asyncio a natural fit to your style.
> equivalent referred to frequently as "callback hell",
A slanderous comment that's not really deserved :-) NodeJS code
many warts!). It's certainly not too difficult to work with
for anyone familiar with callbacks in any other language.
> idiomatic usage of asyncio. Callbacks are supported, because they are
> useful in several instances, but they should not be the only (or even main,
> usually) way asyncio is used.
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.
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor