1
from aioredis import (
    create_redis_pool
)

class RedisConn:
    def __init__(self):
        self.conn = None

    def set_conn(self, c):
        self.conn = c

    def get_conn(self):
        return self.conn


rdpsc = RedisConn()


async def init_redis_conn():
    connection = None
    try:
        connection = await create_redis_pool(
            'redis://localhost:6379',
            db=1
        )
        rdpsc.set_conn(connection)
    except Exception as excep:
        sentry_sdk.capture_exception(excep)

I am getting this error Task was destroyed but it is pending! while using await init_redis_conn(), I am using aioredis=1.3.1 with Python 3.8. Please help me thanks

pdw
  • 8,359
  • 2
  • 29
  • 41
Kanav Raina
  • 43
  • 1
  • 9
  • 1
    "this error", what error ? – azro Jun 04 '21 at 17:51
  • also as a side note instead of using those `get_` and `set_` methods use the `getter` and `setter` decorators – gold_cy Jun 04 '21 at 17:53
  • I am getting this error ERROR: Task was destroyed but it is pending! task: wait_for=()]> cb=[RedisConnection.__init__..() at /home/kanav/contract/thinkv/lib/python3.8/site-packages/aioredis/connection.py:168]> – Kanav Raina Jun 04 '21 at 17:57

0 Answers0