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

Cache.REDIS: issubclass() arg 1 must be a class #539

Open
liquiddandruff opened this issue Jun 3, 2021 · 3 comments
Open

Cache.REDIS: issubclass() arg 1 must be a class #539

liquiddandruff opened this issue Jun 3, 2021 · 3 comments

Comments

@liquiddandruff
Copy link

liquiddandruff commented Jun 3, 2021

In trying https://stackoverflow.com/questions/65686318/sharing-python-objects-across-multiple-workers I've encountered this exception.

Seems hit same issue here: pydantic/pydantic#545 (comment)

From docker stderr:

app_1    |   File "/app/./main.py", line 8, in <module>
app_1    |     cache = Cache(Cache.REDIS, endpoint="localhost", port=6379, namespace="main")
app_1    |   File "/usr/local/lib/python3.8/site-packages/aiocache/factory.py", line 65, in __new__
app_1    |     assert issubclass(cache_class, BaseCache)
app_1    | TypeError: issubclass() arg 1 must be a class

REPL:

>>> from aiocache import Cache
ujson module not found, using json
msgpack not installed, MsgPackSerializer unavailable
>>> Cache()
<aiocache.backends.memory.SimpleMemoryCache object at 0x1085fd820>
>>> Cache(Cache.REDIS)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/variant23/repos/mintad-validator/venv/lib/python3.8/site-packages/aiocache/factory.py", line 65, in __new__
    assert issubclass(cache_class, BaseCache)
TypeError: issubclass() arg 1 must be a class
>>> type(Cache.REDIS)
<class 'NoneType'>
>>> print(Cache.REDIS)
None
>>> print(Cache.MEMORY)
<class 'aiocache.backends.memory.SimpleMemoryCache'>

Packages:

aiocache==0.11.1
fastapi==0.65.1
pydantic==1.8.2

EDIT: Wasn't able to resolve the issue, ended up using aioredis instead.

@ofirzh
Copy link

ofirzh commented Jun 20, 2021

add lib aioredis==1.3.1 to requirments.txt

@ansidorov
Copy link

ansidorov commented Aug 9, 2021

I get a similar error:

>>> from aiocache import Cache
ujson module not found, using json
>>> Cache(Cache.MEMCACHED)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/slurm/py39/lib/python3.9/site-packages/aiocache/factory.py", line 65, in __new__
    assert issubclass(cache_class, BaseCache)
TypeError: issubclass() arg 1 must be a class

>>> Cache(Cache.MEMCACHED)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/slurm/py39/lib/python3.9/site-packages/aiocache/factory.py", line 65, in __new__
    assert issubclass(cache_class, BaseCache)
TypeError: issubclass() arg 1 must be a class

In this case, installing aiomcache helped:
pip install aiomcache
Although the README specifies other package names https://github.com/aio-libs/aiocache#id2

@Dreamsorcerer
Copy link
Member

If someone wants to add a None check and produce a better error, that makes it clear you need to install the required libraries, that would be great.

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

4 participants