omnilib / aiomultiprocess

Take a modern Python codebase to the next level of performance.
https://aiomultiprocess.omnilib.dev
MIT License
1.75k stars 99 forks source link

Adding Connection Pool functionality to pool workers #187

Open jhirschibar opened 1 year ago

jhirschibar commented 1 year ago

Description

Aiomultiprocess is exceptionally good at scaling network requests. However, the abstraction of tasks to queues scheduled amongst pool workers makes it impossible to enable connection pools for each worker in the current state. Using aiohttp's requests method results in a new session being created for every request, which degrades performance.

This PR nests each pool workers target .run() function within an async context manager that creates an aiohttp clientsession and passes the session into the tasks args.

The PR in its current state will need some clean up before it is ready for merge, but I wanted to submit as a WIP to see if a contribution such as this would even be considered.