From 89132bb90b66902400dff9b861eb8a199a2ec149 Mon Sep 17 00:00:00 2001 From: m0wer Date: Wed, 17 Jul 2024 10:34:46 +0200 Subject: [PATCH] feat: add tiemouts to aiohttp requests --- backend/app/models/feed.py | 2 +- backend/tests/e2e/test_e2e_all.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/models/feed.py b/backend/app/models/feed.py index 6a73b53..01b9ca9 100644 --- a/backend/app/models/feed.py +++ b/backend/app/models/feed.py @@ -163,7 +163,7 @@ async def parse_feed(feed_url: HttpUrl) -> Feed: r"^(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b", feed_url.host ): raise RuntimeError("Invalid URL") - async with ClientSession() as aiohttp_session: + async with ClientSession(timeout=10) as aiohttp_session: try: async with aiohttp_session.get( str(feed_url), diff --git a/backend/tests/e2e/test_e2e_all.py b/backend/tests/e2e/test_e2e_all.py index 8030278..3f8457d 100644 --- a/backend/tests/e2e/test_e2e_all.py +++ b/backend/tests/e2e/test_e2e_all.py @@ -47,7 +47,7 @@ class TestGetFeeds: @pytest.mark.asyncio async def test_get_feeds_new_user(self): """Test the main use case with a new user.""" - async with ClientSession() as session: + async with ClientSession(timeout=30) as session: # get all feeds at once results = await asyncio.gather( *[