When substantial new features appear in Python, they’re new for
everybody: even though I have nearly two decades’ experience with
Python, I found Asyncio substantially different to my existing
knowledge, even taking into account that I had already worked with
Twisted and Tornado on previous projects, so event-based
programming was not new to me. I found the asyncio
API to be much more
complex than I had expected. Part of this was due to a lack of
high-level documentation.
Now, having spent the time to learn how to use Asyncio in Python, I feel
a lot more comfortable with it, and this progression will likely be
similar for you too. There is a coherent structure and a purpose
behind the design of the API, and hopefully this book will make it
much easier for you to learn than it was for me. With a basic
understanding in place, I am finding it quite easy to write
new asyncio
-based code without having to constantly refer back to the
docs: this is a very good sign, and certainly isn’t the case with all the
standard library modules.
There are still some rough edges.
The asyncio
standard library will continue to have a large,
fine-grained API, since it caters to both framework designers, as well
as end-user developers. This means that we—as end-user
developers—will have to learn which parts of the API are applicable
to us, and which are not. In time, as the third-party library
ecosystem for asyncio
grows and matures, we will likely be working
with those library APIs rather than the raw asyncio
standard library
API. Existing libraries like aiohttp
and Sanic
are good examples
of this.
The asyncio
API itself will also continue to improve as more people
gain experience with it. As covered earlier in the book, there are
many improvements to asyncio
coming in Python 3.7, and
there is also work currently under way for more substantial improvements
like Task-local storage,
analogous to thread-local storage for threaded programming, but instead
for asyncio
Task
contexts.
There were also unexpected discoveries I made along the way: by happy
coincidence, it turned out that I needed to (finally!) learn ZeroMQ at
around the same time this book was being written. I am finding that
asyncio
in combination with pyzmq
makes network programming a joy!
Finally, my recommendation for the best way to learn Asyncio is to experiment, try things out, and have fun!
3.142.156.255