catch soap timeout error
This commit is contained in:
parent
e8ec88cbf8
commit
ad63f3e853
1 changed files with 10 additions and 4 deletions
|
@ -1,7 +1,9 @@
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import asyncio
|
||||||
import typing
|
import typing
|
||||||
from aioupnp.protocols.scpd import scpd_post
|
from aioupnp.protocols.scpd import scpd_post
|
||||||
|
from aioupnp.fault import UPnPError
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -27,10 +29,14 @@ class SOAPCommand:
|
||||||
raise Exception("argument mismatch: %s vs %s" % (kwargs.keys(), self.param_types.keys()))
|
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]
|
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()}
|
soap_kwargs = {n: self.param_types[n](kwargs[n]) for n in self.param_types.keys()}
|
||||||
|
try:
|
||||||
response, xml_bytes = await scpd_post(
|
response, xml_bytes = await scpd_post(
|
||||||
self.control_url, self.gateway_address, self.service_port, self.method, self.param_order, self.service_id,
|
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
|
close_after_send, self.soap_socket, **soap_kwargs
|
||||||
)
|
)
|
||||||
|
except asyncio.TimeoutError as err:
|
||||||
|
raise UPnPError(err)
|
||||||
|
|
||||||
self._requests.append((soap_kwargs, xml_bytes))
|
self._requests.append((soap_kwargs, xml_bytes))
|
||||||
if not response:
|
if not response:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in a new issue