【发布时间】:2020-10-28 09:40:47
【问题描述】:
我按照these instructions(即sudo apt-get install redis-server)在Windows 10 上的Ubuntu Linux 子系统中安装了Redis 4.0.9 版。
我在 Django 频道上关注this tutorial,我运行了以下代码:
>>> import channels.layers
>>> channel_layer = channels.layers.get_channel_layer()
>>> from asgiref.sync import async_to_sync
>>> async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})
>>> async_to_sync(channel_layer.receive)('test_channel')
当执行上面的最后一行时,我得到这个错误:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line 120, in __call__
return call_result.result()
File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()
File "C:\Users\xyz\Anaconda3\envs\django\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\asgiref\sync.py", line 180, in main_wrap
result = await self.awaitable(*args, **kwargs)
File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 485, in receive
return (await self.receive_single(channel))[1]
File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 508, in receive_single
index, channel_key, timeout=self.brpop_timeout
File "C:\Users\xyz\Anaconda3\envs\django\lib\site-packages\channels_redis\core.py", line 345, in _brpop_with_clean
result = await connection.bzpopmin(channel, timeout=timeout)
aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'
在this page,有人建议使用 Redis 版本 5。如何在 Windows 10 上安装 Redis 版本 5?关于如何解决此问题的任何其他想法?
【问题讨论】:
-
Rune Kaagaard 发布了一个 Answer 说“在 ubuntu 16.04 上使用这个 ppa:launchpad.net/~chris-lea/+archive/ubuntu/redis-server”
-
我也在使用 WSL,问题不在于 windows,而是我在包中使用的 redis 版本,如 @MarvinCorreia 所述
标签: redis django-channels