Skip to content

Commit

Permalink
Catch OSError and socket.gaierror (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored and lwis committed Oct 3, 2018
1 parent a421633 commit 514669b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pytradfri/api/aiocoap_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import asyncio
import json
import logging
import socket

from aiocoap import Message, Context
from aiocoap.error import RequestTimedOut, Error, ConstructionRenderableError
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 514669b

Please sign in to comment.