redis / redis-om-python

Object mapping, and more, for Redis and Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coroutine 'has_redisearch' was never awaited

khiemdoan opened this issue · comments

I got this error without any detail or trace stack:

sys:1: RuntimeWarning: coroutine 'has_redisearch' was never awaited

I commented out these lines in aredis_om/model/model.py and my code run as I expected:

if not has_redisearch(model.db()):
raise RedisModelError(
"Your Redis instance does not have either the RediSearch module "
"or RedisJSON module installed. Querying requires that your Redis "
"instance has one of these modules installed."
)

# if not has_redisearch(model.db()):
#     raise RedisModelError(
#         "Your Redis instance does not have either the RediSearch module "
#         "or RedisJSON module installed. Querying requires that your Redis "
#         "instance has one of these modules installed."
#     )

that is because the __init__() in the class is synchronous but the has_redissearch() method is async.
A way to solve it would either change the class to have an async instance or to run that function using asyncio.run()
check this source for more info.
https://stackoverflow.com/questions/33128325/how-to-set-class-attribute-with-await-in-init