mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Improve aiohttp default clientsession close with connector (#5208)
This commit is contained in:
parent
81922b88a2
commit
ca4a857532
@ -34,7 +34,6 @@ def async_get_clientsession(hass, verify_ssl=True):
|
|||||||
connector=connector,
|
connector=connector,
|
||||||
headers={USER_AGENT: SERVER_SOFTWARE}
|
headers={USER_AGENT: SERVER_SOFTWARE}
|
||||||
)
|
)
|
||||||
_async_register_clientsession_shutdown(hass, clientsession)
|
|
||||||
hass.data[key] = clientsession
|
hass.data[key] = clientsession
|
||||||
|
|
||||||
return hass.data[key]
|
return hass.data[key]
|
||||||
@ -111,8 +110,12 @@ def async_cleanup_websession(hass):
|
|||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
"""
|
"""
|
||||||
tasks = []
|
tasks = []
|
||||||
|
if DATA_CLIENTSESSION in hass.data:
|
||||||
|
hass.data[DATA_CLIENTSESSION].detach()
|
||||||
if DATA_CONNECTOR in hass.data:
|
if DATA_CONNECTOR in hass.data:
|
||||||
tasks.append(hass.data[DATA_CONNECTOR].close())
|
tasks.append(hass.data[DATA_CONNECTOR].close())
|
||||||
|
if DATA_CLIENTSESSION_NOTVERIFY in hass.data:
|
||||||
|
hass.data[DATA_CLIENTSESSION_NOTVERIFY].detach()
|
||||||
if DATA_CONNECTOR_NOTVERIFY in hass.data:
|
if DATA_CONNECTOR_NOTVERIFY in hass.data:
|
||||||
tasks.append(hass.data[DATA_CONNECTOR_NOTVERIFY].close())
|
tasks.append(hass.data[DATA_CONNECTOR_NOTVERIFY].close())
|
||||||
|
|
||||||
|
@ -284,8 +284,7 @@ class TestMediaPlayerWeb(unittest.TestCase):
|
|||||||
def get(self, url):
|
def get(self, url):
|
||||||
return MockResponse()
|
return MockResponse()
|
||||||
|
|
||||||
@asyncio.coroutine
|
def detach(self):
|
||||||
def close(self):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.hass.data[DATA_CLIENTSESSION] = MockWebsession()
|
self.hass.data[DATA_CLIENTSESSION] = MockWebsession()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user