From 514669b66500b81eb591a89c0c031591a9d0969f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 3 Oct 2018 22:08:56 +0200 Subject: [PATCH] Catch OSError and socket.gaierror (#189) --- pytradfri/api/aiocoap_api.py | 5 ++++- setup.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pytradfri/api/aiocoap_api.py b/pytradfri/api/aiocoap_api.py index c8d92af3..8d917f00 100644 --- a/pytradfri/api/aiocoap_api.py +++ b/pytradfri/api/aiocoap_api.py @@ -2,6 +2,7 @@ import asyncio import json import logging +import socket from aiocoap import Message, Context from aiocoap.error import RequestTimedOut, Error, ConstructionRenderableError @@ -98,7 +99,9 @@ async def _get_response(self, msg): except RequestTimedOut as e: await self._reset_protocol(e) raise RequestTimeout('Request timed out.', e) - except Error as e: + except (OSError, socket.gaierror, Error) as e: + # aiocoap sometimes raises an OSError/socket.gaierror too. + # aiocoap issue #124 await self._reset_protocol(e) raise ServerError("There was an error with the request.", e) except asyncio.CancelledError as e: diff --git a/setup.py b/setup.py index e7757315..5efc2d4d 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() -VERSION = "6.0.0" +VERSION = "6.0.1" DOWNLOAD_URL = \ 'https://github.com/ggravlingen/pytradfri/archive/{}.zip'.format(VERSION)