From 0a23fc1efc622fedef445509be91c563d4ed3112 Mon Sep 17 00:00:00 2001 From: ehendrix23 Date: Mon, 23 Aug 2021 12:40:19 -0600 Subject: [PATCH] v3.1.3 (#119) * Check auth only for login * Update user agent on connection reset (54) * Only set user agent when error * Version 3.1.1 * Include errno 104 for retrieving user agent * Bump to 3.1.2 * Add ClientOSError exception * version 3.1.3 * Handle ServerDisconnectedError --- pymyq/__version__.py | 2 +- pymyq/request.py | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pymyq/__version__.py b/pymyq/__version__.py index 1e4f1d2..a31cff8 100644 --- a/pymyq/__version__.py +++ b/pymyq/__version__.py @@ -1,2 +1,2 @@ """Define a version constant.""" -__version__ = "3.1.2" +__version__ = "3.1.3" diff --git a/pymyq/request.py b/pymyq/request.py index 15b929b..f4f48ee 100644 --- a/pymyq/request.py +++ b/pymyq/request.py @@ -8,7 +8,12 @@ from typing import Optional, Tuple from aiohttp import ClientResponse, ClientSession -from aiohttp.client_exceptions import ClientError, ClientResponseError +from aiohttp.client_exceptions import ( + ClientError, + ClientOSError, + ClientResponseError, + ServerDisconnectedError, +) from .errors import RequestError @@ -170,11 +175,12 @@ async def _send_request( ) await self._get_useragent() - except ClientError as err: - if err.errno in (54, 104) and attempt == 0: + except (ClientOSError, ServerDisconnectedError) as err: + errno = getattr(err, "errno", -1) + if errno in (-1, 54, 104) and attempt == 0: _LOGGER.debug( "Received error status %s, connection reset. Will refresh user agent.", - err.errno, + errno, ) await self._get_useragent() else: @@ -187,6 +193,16 @@ async def _send_request( last_error = str(err) resp_exc = err + except ClientError as err: + _LOGGER.debug( + "Attempt %s request failed with exception: %s", + attempt, + str(err), + ) + last_status = "" + last_error = str(err) + resp_exc = err + if resp_exc is not None: raise resp_exc