我得到这个错误:任务已被销毁,但它是挂起的

2024-06-08 05:43:18 发布

您现在位置:Python中文网/ 问答频道 /正文

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)

我在使用await init_redis_conn()时遇到了这个错误Task was destroyed but it is pending!,我在Python3.8中使用了aioredis=1.3.1。请帮帮我谢谢


Tags: selfredisnoneinitdefcreateawaitconnection

热门问题