pipreqs
pipreqs copied to clipboard
feat: Add Asynchronous Web Requests
This PR migrates from synchronous requests to asynchronous httpx for making HTTP requests to PyPI, aiming to improve performance by enabling concurrent API calls when resolving package information.
- Replaced
requestswithhttpxfor asynchronous HTTP requests - Added
async/awaitpattern toget_imports_infoand init functions - Implemented concurrent requests using
asyncio.gather()for better performance
Transition to Asynchronous Code:
- Refactored
get_imports_infoto an asynchronous function (async def) and split out_get_responseas a helper function for making asynchronous HTTP requests usinghttpx. This allows concurrent fetching of package data from PyPI, improving performance. - Updated the
initfunction to be asynchronous and usedasyncio.runin themainfunction to execute it, enabling the integration of asynchronous workflows throughout the application. [1] [2] - Modified the call to
get_imports_infoininitto useawait, ensuring proper handling of asynchronous operations.
Library Replacement:
- Replaced the
requestslibrary withhttpxfor HTTP requests, enabling asynchronous request handling and modernizing the codebase.