Async clientsession / fix stuff on aiohttp and camera platform (#4084)
* add websession * convert to websession * convert camera to async * fix lint * fix spell * add import * create task to loop * fix test * update aiohttp * fix tests part 2 * Update aiohttp.py
This commit is contained in:
1 parent
85747fe2ef
commit
3324995e70
5 files changed
+199
-121
No files matched your search
@@ -73,7 +73,6 @@ class GenericCamera(Camera):
|
||||
|
||||
self._last_url = None
|
||||
self._last_image = None
|
||||
self._session = aiohttp.ClientSession(loop=hass.loop, auth=self._auth)
|
||||
|
||||
def camera_image(self):
|
||||
"""Return bytes of camera image."""
|
||||
@@ -111,7 +110,10 @@ class GenericCamera(Camera):
|
||||
else:
|
||||
try:
|
||||
with async_timeout.timeout(10, loop=self.hass.loop):
|
||||
respone = yield from self._session.get(url)
|
||||
respone = yield from self.hass.websession.get(
|
||||
url,
|
||||
auth=self._auth
|
||||
)
|
||||
self._last_image = yield from respone.read()
|
||||
self.hass.loop.create_task(respone.release())
|
||||
except asyncio.TimeoutError:
|
||||
|
||||
Reference in new issue
Block a user