Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if not (cache_class and issubclass(cache_class, BaseCache)): TypeError: issubclass() arg 1 must be a class #957

Open
yuanjie-ai opened this issue Feb 3, 2025 · 2 comments

Comments

@yuanjie-ai
Copy link

import asyncio

from collections import namedtuple

from aiocache import cached, Cache, RedisCache
from aiocache.serializers import PickleSerializer
# With this we can store python objects in backends like Redis!

Result = namedtuple('Result', "content, status")


@cached(
    cache=RedisCache(), key="key", serializer=PickleSerializer(), port=6379, namespace="main")
async def cached_call():
    print("Sleeping for three seconds zzzz.....")
    await asyncio.sleep(3)
    return Result("content", 200)


async def run():
    await cached_call()
    await cached_call()
    await cached_call()
    cache = Cache(Cache.REDIS, endpoint="127.0.0.1", port=6379, namespace="main")
    await cache.delete("key")

if __name__ == "__main__":
    asyncio.run(run())
@Dreamsorcerer
Copy link
Member

Traceback?

@maximkz561
Copy link

Traceback (most recent call last):
  File "file.py", line 12, in <module>
    @cached(
     ^^^^^^^
  File "/path/to/venv/lib/python3.12/site-packages/aiocache/decorators.py", line 99, in __call__
    self.cache = _get_cache(
                 ^^^^^^^^^^^
  File "/path/to/venv/lib/python3.12/site-packages/aiocache/decorators.py", line 238, in _get_cache
    return Cache(cache, serializer=serializer, plugins=plugins, **cache_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/venv/lib/python3.12/site-packages/aiocache/factory.py", line 63, in __new__
    if not (cache_class and issubclass(cache_class, BaseCache)):
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

Same error for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants