繁体   English   中英

Channels_redis 导致错误 AttributeError: 'Redis' object has no attribute 'bzpopmin'

[英]Channels_redis causing the error AttributeError: 'Redis' object has no attribute 'bzpopmin'

我在 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-cli INFO | grep version I can see the version of Redis installed on my machine is 6.0.9 which also applies when calling a similar function from within Python.

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

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

我有同样的错误并通过更新aioredis修复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM