我目前正在尝试使用 Celery 通过 django channel 发送套接字。然而,我发现了与使用 Django 的 shell 相同的问题,希望有人能启发我。
我已将其设置为在views.py 中,当用户发送 POST 请求时,它将调用
Group("chat").send({'text':'hello'})
然后浏览器会显示一条警报。
但是,当我尝试使用 Django 的 shell 或 Celery 的任务之一执行相同的操作时:
$ python3 manage.py shell
$ from channels import Group
$ Group("chat").send({'text': 'hello'})
它不执行任何操作,甚至不返回错误。
最佳答案
如果您使用内存中
channel 层,那么可能它不支持跨进程通信。
因此尝试使用其他 channel 层类型,就可以了.
关于python - 使用 django shell 的 Django channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39114502/