小编Chr*_*ris的帖子

Django Channels 2.0 channel_layers没有通信

所以我一直在迁移使用Django Channels 1.x - > 2.x +的服务器

原始设计会将任务发送给芹菜使用,getAFTreeTask.delay(message.reply_channel.name)并且通过访问channel_name它可能会异步地回复

from celery import task
from channels import Channel

@task
def getAFTreeTask(channel_name):
    tree = Request().cache_af_tree()
    Channel(channel_name).send({
        "text": json.dumps({
            "channel": "AF_INIT",
            "payload": tree
        })
    })
Run Code Online (Sandbox Code Playgroud)

现在我出于各种原因将我的服务器迁移到Channels 2.x +.根据文件

class Consumer(JsonWebsocketConsumer):

     def connect(self):
        print("Client Connected: ", self.channel_name)
        self.accept()

    def receive_json(self, content, **kwargs):
        print(content)
        parse_request(self.channel_name, content)

    def disconnect(self, content):
        print(content)

    def chat_message(self, event):
        print("Entered reply channel")
        print(event)
Run Code Online (Sandbox Code Playgroud)

像这样设置的消费者应该通过渠道层接收请求,前提是我使用正确的channel_name,现在消费者可以正确地作为发送 - 接收websocket,如果响应可以访问self.send_json()self.send()为其他普通消费者访问,所以我假设所有我的设置是正确的,我的问题是当我尝试使用通道层发送一些东西时,这样(根据https://channels.readthedocs.io/en/latest/topics/channel_layers.html#single-channels)

from channels.layers import get_channel_layer
from asgiref.sync …
Run Code Online (Sandbox Code Playgroud)

python django websocket celery django-channels

2
推荐指数
1
解决办法
2630
查看次数

在Linux中编写程序,OpenGL,Wayland和Qt如何适应图片

人们通常如何通过窗口GUI和3D渲染的混合来制作GUI程序?即SolidWorks

更具体地说:由于缺乏更好的描述,似乎OpenGL更适合渲染和创建3D对象/世界,而3D对象/世界更像游戏。因此,例如,如果我想使用OpenGL创建GUI(即MATLAB),则必须对所有字符信息进行编程以从头开始进行文本编辑,按钮等操作,这似乎很荒谬。因此,如果我想创建这些窗口,则将使用Qt之类的构建器并具有其所有功能,但是我会受到限制,如果我想在Qt中创建精美的3D模型,则必须使用所有非Qt函数。不如OpenGl好吗?(Wayland怎么也适合这张照片?)

c++ linux opengl user-interface qt

1
推荐指数
1
解决办法
1885
查看次数

标签 统计

c++ ×1

celery ×1

django ×1

django-channels ×1

linux ×1

opengl ×1

python ×1

qt ×1

user-interface ×1

websocket ×1