From ad63f3e8534a6e1bc8fdb049a4e105679013d391 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 12 Oct 2018 13:20:09 -0400 Subject: [PATCH] catch soap timeout error --- aioupnp/protocols/soap.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/aioupnp/protocols/soap.py b/aioupnp/protocols/soap.py index 812a21d..390d81a 100644 --- a/aioupnp/protocols/soap.py +++ b/aioupnp/protocols/soap.py @@ -1,7 +1,9 @@ import logging import socket +import asyncio import typing from aioupnp.protocols.scpd import scpd_post +from aioupnp.fault import UPnPError log = logging.getLogger(__name__) @@ -27,10 +29,14 @@ class SOAPCommand: raise Exception("argument mismatch: %s vs %s" % (kwargs.keys(), self.param_types.keys())) close_after_send = not self.return_types or self.return_types == [None] soap_kwargs = {n: self.param_types[n](kwargs[n]) for n in self.param_types.keys()} - response, xml_bytes = await scpd_post( - self.control_url, self.gateway_address, self.service_port, self.method, self.param_order, self.service_id, - close_after_send, self.soap_socket, **soap_kwargs - ) + try: + response, xml_bytes = await scpd_post( + self.control_url, self.gateway_address, self.service_port, self.method, self.param_order, self.service_id, + close_after_send, self.soap_socket, **soap_kwargs + ) + except asyncio.TimeoutError as err: + raise UPnPError(err) + self._requests.append((soap_kwargs, xml_bytes)) if not response: return None