GNews icon indicating copy to clipboard operation
GNews copied to clipboard

Implement Async Support

Open ranahaani opened this issue 2 months ago • 5 comments

Description

Implement comprehensive async/await support for GNews using aiohttp to enable concurrent requests and significantly improve performance for bulk operations. This will make GNews suitable for high-performance applications.

Why?

Async support enables concurrent requests, which can be 10x faster for bulk operations. Many modern Python applications use async/await, and this will make GNews compatible with async frameworks like FastAPI, asyncio, and others.

How?

Create a new async_gnews.py file with:

  • GNewsAsync class with async methods
  • Use aiohttp for HTTP requests instead of urllib
  • Implement concurrent request handling
  • Maintain API compatibility with synchronous version
  • Add proper async context management

Files to Create

  • gnews/async_gnews.py

Files to Modify

  • requirements.txt (add aiohttp dependency)
  • gnews/__init__.py (export async class)

Acceptance Criteria

  • [ ] GNewsAsync class created with async methods
  • [ ] All synchronous methods have async equivalents
  • [ ] Concurrent request handling implemented
  • [ ] Proper error handling for async operations
  • [ ] Context manager support (async with)
  • [ ] Performance improvements demonstrated
  • [ ] Tests added for async functionality
  • [ ] Documentation updated with async examples

Example Usage

import asyncio
from gnews import GNewsAsync

async def main():
    async with GNewsAsync() as gnews:
        # Concurrent requests
        tasks = [
            gnews.get_news('AI'),
            gnews.get_news('Machine Learning'),
            gnews.get_news('Deep Learning')
        ]
        results = await asyncio.gather(*tasks)
        return results

# Run async function
results = asyncio.run(main())

Resources

Difficulty: Medium

Time Estimate: 3-5 hours

ranahaani avatar Oct 21 '25 04:10 ranahaani

can you assign this to me?

Mmadan128 avatar Oct 21 '25 20:10 Mmadan128

i want to work on this issue can you kindly assign it to me i am familiar with async files and have worked on real world projects that must needs these features hence i can take on this issue without facing much difficulty if you assign it to me

ASHUTOSH-A-49 avatar Oct 23 '25 16:10 ASHUTOSH-A-49

i would like to work in this issue. please assign this issue to me @ranahaani

AnaghDeshpande avatar Oct 25 '25 17:10 AnaghDeshpande

@AnaghDeshpande Hi, I saw this project and the issue is quite necessary for me. Can I take it and I'll try to integrate my first changes into your project? And tell me, have you done anything? So that neither you nor I do the same thing.

cicwak avatar Nov 07 '25 10:11 cicwak

i create a pr https://github.com/ranahaani/GNews/pull/156

cicwak avatar Nov 07 '25 14:11 cicwak