pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

feat: Add Asynchronous Web Requests

Open mertemr opened this issue 4 months ago • 0 comments

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 requests with httpx for asynchronous HTTP requests
  • Added async/await pattern to get_imports_info and init functions
  • Implemented concurrent requests using asyncio.gather() for better performance

Transition to Asynchronous Code:

  • Refactored get_imports_info to an asynchronous function (async def) and split out _get_response as a helper function for making asynchronous HTTP requests using httpx. This allows concurrent fetching of package data from PyPI, improving performance.
  • Updated the init function to be asynchronous and used asyncio.run in the main function to execute it, enabling the integration of asynchronous workflows throughout the application. [1] [2]
  • Modified the call to get_imports_info in init to use await, ensuring proper handling of asynchronous operations.

Library Replacement:

  • Replaced the requests library with httpx for HTTP requests, enabling asynchronous request handling and modernizing the codebase.

mertemr avatar Aug 04 '25 06:08 mertemr