Skip to content

Commit

Permalink
v3.1.3 (#119)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ehendrix23 authored Aug 23, 2021
1 parent 151092f commit 0a23fc1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pymyq/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Define a version constant."""
__version__ = "3.1.2"
__version__ = "3.1.3"
24 changes: 20 additions & 4 deletions pymyq/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit 0a23fc1

Please sign in to comment.