tl;dr ensure_future let’s us execute a coroutine in the background, without explicitly waiting for it to finish. If we need, we can wait for it later or poll for result. In other words, this is a way of executing code in asyncio without await.
During application development with asyncio you will inevitably encounter situation when there is no asyncio-compatible library to use. It may be an API client for our business partner built with excellent requests library (that naturally doesn’t work well with asyncio)… Continue Reading →
Protocols are asyncio’s primitives supplied as convenient base classes to quickly set up clients or servers using TCP/UDP (+ subprocesses). These are especially helpful when we need to implement low level handling of protocol of some sort. I believe they… Continue Reading →
Let’s roll with something practical, namely a simple chat application using Sanic framework mentioned in previous post. Sanic supports websockets out of the box thanks to the websockets library. It’s super easy to write a handler function by using decorator… Continue Reading →
Few days ago while I was reading fullstackpython.com I came across new pythonic micro web framework based on asyncio – Sanic. Coolest thing about Sanic is that it leverages asyncio providing better performance and more efficient hardware utilization. Although it’s… Continue Reading →
Concurrency was not seriously taken into account in Python when it was designed. Until 3.4 version, there were two options: threading multiprocessing Although these two modules provided programmers with handy primitives and API, they both have considerable downsides. Due to… Continue Reading →