Skip to content

Async Cache session expire_after does not set properly #149

@N4S4

Description

@N4S4

Good dday,

With below code:

import asyncio
from homeassistant_api import Client
from aiohttp_client_cache import CachedSession, FileBackend
from datetime import timedelta
import logging

logging.basicConfig(filename='log.log', encoding='utf-8', level=logging.DEBUG)

hassurl = 'MY URL'
token = 'MY TOKEN'

client = Client(
    hassurl,
    token,
    async_cache_session=CachedSession(cache=FileBackend(),
                                      expire_after=timedelta(seconds=5)),
    use_async=True
)


async def main():
    async with client:
        while True:
            door = await client.async_get_state(entity_id='sensor.testing')
            if door.state == 'on':

                return True
            else:
                print(door)


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

whenever I run this code it works properly except for the update of the cache

looking at the debug log i find this string:

DEBUG:aiohttp_client_cache.cache_control:Determining expiration time based on: -1

whatever I set as expire_after in CachedSession it will always be set to -1

does this event occur to me only?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions