Python and Async Simplified (2018)
aeracode.org
Python and Async Simplified (2018)
1–10 of 47 posts
Re: Python and Async Simplified (2018)
#2While I am self-taught, I'm used to (academic) books that strive for completeness. It is also what I prefer. Rather than something more pragmatic like a blog post.
It doesn't mean I want to read overly complicated prose on the subject, which I'm sure is possible.
Re: Python and Async Simplified (2018)
#3Can anyone recommend a good book/primer on "concurrency models" (is that a term?) for a self-taught programmer? While I am self-taught, I'm used to (academic) books that strive for completeness. It is also what I prefer. Rather than something more pragmatic like a blog post. It doesn't mean I want to read overly complicated prose on the subject, which I'm sure is possible.
This is much more useful than the typical "let's write a single-run example with async" blog post.
Re: Python and Async Simplified (2018)
#4There are popular libraries for it in both Python and Perl and I suspect I could make good use for it if I understood it.
Unfortunately, I've only ever used it in a cargo cult manner of sticking together functions until the error messages go away (yeah yeah, it was only for "throwaway" "prototypes") so I really don't understand how it all is meant to fit together.
Re: Python and Async Simplified (2018)
#5When teaching it, it's important to emphasis:
- await is locally blocking, so you should isolate linear workflows into their own coro, which is the unit of concurrency.
- to allow concurrency, you should use asyncio.create_task on coro (formerly ensure_future).
- you should always explicitly delimitate the life cycle of any task. Right now, this means using something like gather() or wait(). TaskGroup will help when it becomes mainstream.
A HN comment is not great to explain that, but if you read the article, you should investigate those points. There is no good asyncio code without them, only pain and disapointment.
Re: Python and Async Simplified (2018)
#6Can anyone recommend a good book/primer on "concurrency models" (is that a term?) for a self-taught programmer? While I am self-taught, I'm used to (academic) books that strive for completeness. It is also what I prefer. Rather than something more pragmatic like a blog post. It doesn't mean I want to read overly complicated prose on the subject, which I'm sure is possible.
The whole async thing is there to abstract away and not have the program structured around the main loop… but in reality you have to keep in mind you are in a main loop that calls poll() and then all the registered functions.
Re: Python and Async Simplified (2018)
#7It gives good pointers but it falls short on the usual suspects for an article on asyncio. When teaching it, it's important to emphasis: - await is locally blocking, so you should isolate linear workflows into their own coro, which is the unit of concurrency. - to allow concurrency, you should use asyncio.create_task on coro (formerly ensure_future). - you should always explicitly delimitate the life cycle of any tas…
Unless you want a hacky actor system, in which case it's totally fine to `create_task` a ton of corountines which have their own spin loop with await sleep :)
Re: Python and Async Simplified (2018)
#8Re: Python and Async Simplified (2018)
#9Can anyone recommend a good book/primer on "concurrency models" (is that a term?) for a self-taught programmer? While I am self-taught, I'm used to (academic) books that strive for completeness. It is also what I prefer. Rather than something more pragmatic like a blog post. It doesn't mean I want to read overly complicated prose on the subject, which I'm sure is possible.
Re: Python and Async Simplified (2018)
#10It gives good pointers but it falls short on the usual suspects for an article on asyncio. When teaching it, it's important to emphasis: - await is locally blocking, so you should isolate linear workflows into their own coro, which is the unit of concurrency. - to allow concurrency, you should use asyncio.create_task on coro (formerly ensure_future). - you should always explicitly delimitate the life cycle of any tas…
> you should always explicitly delimitate the life cycle of any task Unless you want a hacky actor system, in which case it's totally fine to `create_task` a ton of corountines which have their own spin loop with await sleep :)