bachya/pytile

Session is closed

paraselene opened this issue · 0 comments

import asyncio

from aiohttp import ClientSession

from pytile import Client

async def main() -> None:
        """Create the aiohttp session and run the example."""
        async with ClientSession() as websession:
                client = Client(account, password, websession)
        await client.async_init()

        # Get all Tiles associated with an account:
        await client.tiles.all()


asyncio.get_event_loop().run_until_complete(main())

I follow the Usage and got the following error

Traceback (most recent call last):
  File "index.py", line 19, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "index.py", line 13, in main
    await client.async_init()
  File "/home/pi/.local/lib/python3.7/site-packages/pytile/client.py", line 50, in async_init
    'locale': self._locale
  File "/home/pi/.local/lib/python3.7/site-packages/pytile/client.py", line 92, in request
    params=params, data=data) as resp:
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/client.py", line 1005, in __aenter__
    self._resp = await self._coro
  File "/home/pi/.local/lib/python3.7/site-packages/aiohttp/client.py", line 348, in _request
    raise RuntimeError('Session is closed')
RuntimeError: Session is closed