From f19e04c96274d662bfea8ac7254f12a2249eecef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 15 Jul 2020 03:28:03 +0200 Subject: [PATCH] fix network errors --- sdbs_infra/dashboard/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdbs_infra/dashboard/views.py b/sdbs_infra/dashboard/views.py index 9ec8f93..907b9ea 100644 --- a/sdbs_infra/dashboard/views.py +++ b/sdbs_infra/dashboard/views.py @@ -6,6 +6,7 @@ from urllib.parse import urlparse import aiohttp import psutil +from aiohttp import ClientConnectorError from bs4 import BeautifulSoup from django.views.generic import TemplateView from humanize import naturalsize @@ -30,12 +31,12 @@ class IndexView(TemplateView): session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=5, sock_connect=1)) for link in links: - index_text = None, None + index_text = None if not link.image: try: async with session.get(link.url) as response: index_status, index_text = response.status, await response.text() - except asyncio.TimeoutError: + except (asyncio.TimeoutError, ClientConnectorError): pass image = link.image.url if link.image else self.extract_favicon(link.url, index_text) @@ -59,7 +60,7 @@ class IndexView(TemplateView): try: async with session.get(service.url) as response: index_status, index_text = response.status, await response.text() - except asyncio.TimeoutError: + except (asyncio.TimeoutError, ClientConnectorError): pass if service.port: