Learning Python Networking - Second Edition
by José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington
Introducing aiohttp
The next module we are going to review is frequently used in conjunction with asyncio. This is because it provides a framework for working with asynchronous requests. It is an excellent solution for complementing the server part of a web application with Python 3.5+ as well.
The main tool for making requests is the requests module. The main problem with requests is that the thread is blocked until we obtain a response. By default, request operations are blocking. When the thread calls a method such as get or post, it pauses until the operation completes.
To download multiple resources at once, we need many threads. At this point, aiohttp allows us to make requests asynchronously. You can install aiohttp by using the
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access