Django Channels: Event loop is closing

报错:

[2022-12-03 22:09:22,113: ERROR/ForkPoolWorker-4] Task exception was never retrieved
future:  exception=RuntimeError('Event loop is closed')>
Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/jc_tool-tC2iUSos/lib64/python3.9/site-packages/redis/asyncio/connection.py", line 824, in disconnect
    self._writer.close()  # type: ignore[union-attr]
  File "/usr/lib64/python3.9/asyncio/streams.py", line 353, in close
    return self._transport.close()
  File "/usr/lib64/python3.9/asyncio/selector_events.py", line 698, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 751, in call_soon
    self._check_closed()
  File "/usr/lib64/python3.9/asyncio/base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

解决方法:

CHANNEL_LAYERS = {
    "default": {
        # "BACKEND": "channels_redis.core.RedisChannelLayer",
        "BACKEND": "channels_redis.pubsub.RedisPubSubChannelLayer",
        "CONFIG": {
            "hosts": [REDIS_URL + '13']
        },
    },
}

来自多线程 - Django 通道:使用线程时事件循环正在关闭 - 堆栈溢出 (stackoverflow.com)

你可能感兴趣的:(Django Channels: Event loop is closing)