【问题标题】:Channels_redis causing the error AttributeError: 'Redis' object has no attribute 'bzpopmin'Channels_redis 导致错误 AttributeError: 'Redis' object has no attribute 'bzpopmin'
【发布时间】:2021-04-10 08:52:10
【问题描述】:

我的 Django 应用程序出现以下错误消息:

Exception inside application: 'Redis' object has no attribute 'bzpopmin'
Traceback (most recent call last):
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/staticfiles.py", line 44, in __call__
    return await self.application(scope, receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/routing.py", line 71, in __call__
    return await application(scope, receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/sessions.py", line 47, in __call__
    return await self.inner(dict(scope, cookies=cookies), receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/sessions.py", line 254, in __call__
    return await self.inner(wrapper.scope, receive, wrapper.send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/auth.py", line 181, in __call__
    return await super().__call__(scope, receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/middleware.py", line 26, in __call__
    return await self.inner(scope, receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/routing.py", line 160, in __call__
    send,
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/consumer.py", line 94, in app
    return await consumer(scope, receive, send)
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/consumer.py", line 59, in __call__
    [receive, self.channel_receive], self.dispatch
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/utils.py", line 58, in await_many_dispatch
    await task
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels/utils.py", line 50, in await_many_dispatch
    result = task.result()
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels_redis/core.py", line 469, in receive
    real_channel
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels_redis/core.py", line 524, in receive_single
    index, channel_key, timeout=self.brpop_timeout
  File "/home/jack/.conda/envs/GuessWhich/lib/python3.7/site-packages/channels_redis/core.py", line 361, in _brpop_with_clean
    result = await connection.bzpopmin(channel, timeout=timeout)
AttributeError: 'Redis' object has no attribute 'bzpopmin'

这似乎是在创建 WebSocket 连接之后,在引发错误后 WebSocket 断开连接。

起初我查看了使用低于 5.0 的 Redis 版本引起的其他类似问题,但在输入命令 redis-cli INFO | grep version 后,我可以看到我机器上安装的 Redis 版本是 6.0.9,这也适用于在 Python 中调用类似的函数。

此时我认为问题可能是由于运行了一个独立版本的 Redis(可能来自其他一些依赖项?),但我在我的机器上找不到这方面的证据,或者由于将通道版本从 1 升级到3 并留下一些遗留代码。我没有成功找到任何与我所面临的问题类似的问题,并且不确定这些假设是否正确。

【问题讨论】:

    标签: python django redis django-channels redis-py


    【解决方案1】:

    要回答我遇到的这个问题,我不能 100% 确定是什么损坏了,但我使用的是 conda 环境,其中混合了通过 conda 和 pip 安装的软件包(pip 似乎也损坏了)。删除并重新创建环境,并使用 pip 安装所有包后,此问题已解决。

    【讨论】:

      【解决方案2】:

      我遇到了同样的错误,并通过更新 aioredis 来修复它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-07
        • 2022-12-01
        • 2022-12-03
        • 1970-01-01
        • 1970-01-01
        • 2014-12-20
        • 2021-11-08
        相关资源
        最近更新 更多