mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +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,
|
||||
headers={USER_AGENT: SERVER_SOFTWARE}
|
||||
)
|
||||
_async_register_clientsession_shutdown(hass, clientsession)
|
||||
hass.data[key] = clientsession
|
||||
|
||||
return hass.data[key]
|
||||
@ -111,8 +110,12 @@ def async_cleanup_websession(hass):
|
||||
This method is a coroutine.
|
||||
"""
|
||||
tasks = []
|
||||
if DATA_CLIENTSESSION in hass.data:
|
||||
hass.data[DATA_CLIENTSESSION].detach()
|
||||
if DATA_CONNECTOR in hass.data:
|
||||
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:
|
||||
tasks.append(hass.data[DATA_CONNECTOR_NOTVERIFY].close())
|
||||
|
||||
|
@ -284,8 +284,7 @@ class TestMediaPlayerWeb(unittest.TestCase):
|
||||
def get(self, url):
|
||||
return MockResponse()
|
||||
|
||||
@asyncio.coroutine
|
||||
def close(self):
|
||||
def detach(self):
|
||||
pass
|
||||
|
||||
self.hass.data[DATA_CLIENTSESSION] = MockWebsession()
|
||||
|
Loading…
x
Reference in New Issue
Block a user