def async_unsubscribe(self, force=False):
"""UNSUBSCRIBE from events on StateVariables."""
if not force and not self._subscription_sid:
raise RuntimeError('Cannot unsubscribed, subscribe first')
subscription_sid = self._subscription_sid
if force:
# we don't care what happens further, make sure we are unsubscribed
self._subscription_sid = None
headers = {
'Host': urllib.parse.urlparse(self.event_sub_url).netloc,
'SID': subscription_sid,
}
try:
response_status, _, _ = \
yield from self._requester.async_http_request('UNSUBSCRIBE',
self.event_sub_url,
headers)
except (asyncio.TimeoutError, aiohttp.ClientError):
if not force:
raise
return
if response_status != 200:
_LOGGER.error('Did not receive 200, but %s', response_status)
return
self._subscription_sid = None
upnp_client.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录