This is an educational package (for myself) and has very limited practical use cases, if any.
aioreq
Minimal performant package to asynchronously make GET requests without any dependencies other than asyncio
.
My goal for this project was to:
- Learn about asynchronous code in a practical manner.
- Build a small package that allows you to send multiple requests asynchronously.
Example
Check out examples/client.py on how to use this package. It is as simple as:
import asyncio
import aioreq
async def main():
urls = [("example.org", 80), ...]
return await aioreq.get_requests(urls)
asyncio.run(main())
Practical use cases of this package
What you can do:
- Handle requests asynchronously without any third-party library.
GET
requests onlyHTTP
requests only- Get the payload as bytes after the connection has been closed. This payload will also include
HTTP
headers.
Basically all advanced things, you can not do using this package. Even basic things like POST
requests are not implemented.
Understanding what is going on
From basic principles (synchronous requests) to a package to handle requests asynchronously without any third-party library:
- experiments/synchronous_client.py - sync.
- experiments/multiplexing.py - async.
- experiments/asyncio_sockets.py - async.
- examples/client.py - async.
Resources
Some resources I have found extremely usefull in the process of developing this small package:
- Build your own async by David Beazly
get_running_loop()
implementation in Python - showing that there can only be one eventloop per thread.- Non-blocking sockets write-up.