Skip to content

yannickperrenet/aioreq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 (from the standard library).

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 using low-level primitives, i.e. not using any third-party package such as aiohttp.

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 only
  • HTTP 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:

  1. experiments/synchronous_client.py - sync.
  2. experiments/multiplexing.py - async.
  3. experiments/asyncio_sockets.py - async.
  4. examples/client.py - async.

Resources

Some resources I have found extremely usefull in the process of developing this small package:

About

🔥 Asynchronously make GET requests using only Python's `asyncio`

Resources

License

Stars

Watchers

Forks

Languages