Multiverse-of-Projects / NewsAI

A dynamic NewsAI dashboard that uses NLP to analyze news articles, visualize sentiment trends, and extract insights through interactive data visualizations.
https://www.youtube.com/watch?v=stTXgljJVPQ
GNU General Public License v3.0
8 stars 6 forks source link

Implement Asynchronous Content Fetching with Retry Logic #39

Open Devasy23 opened 3 days ago

Devasy23 commented 3 days ago

Description:
The goal of this task is to implement an asynchronous function to fetch the content of an article using a URL. The function should handle potential errors, such as failed network requests, and implement a retry mechanism with exponential backoff. The content should be fetched in an efficient manner using aiohttp, and the function should support retrying in case of failures.

Changes:

Example Dummy Code:

from aiohttp import ClientSession
from retrying import retry

@retry(stop_max_attempt_number=3, wait_exponential_multiplier=1000)
async def fetch_content(article_id, url, session: ClientSession):
    try:
        async with session.get(url) as response:
            if response.status == 200:
                return await response.text()
            else:
                raise Exception(f"Failed to fetch article {article_id}: {response.status}")
    except Exception as e:
        print(f"Error fetching content for article {article_id}: {e}")
        raise

# Usage example
async def example_usage():
    async with ClientSession() as session:
        content = await fetch_content('123', 'http://example.com', session)
NavSrijan commented 3 days ago

I would like to work on this issue.

vrajpatelll commented 3 days ago

Hi @NavSrijan , We truly appreciate your interest in this project and value your contributions. However, we want to emphasize the seriousness of the endeavor. Please be assured that the code will undergo thorough review and testing to ensure its quality. Thank you!