使用REDIS实施动态会员协议,以保持工人的客户列表更新
我正在使用Python中的XMLRPC进行大师工作者的架构分配,现在我应该实现动态成员资格协议,以便每当主人修改它(添加或删除工人)时,客户端上的工人列表就会更新,以便客户端不需要在运行命令之前或在运行命令之前请求它。
老师提到的可以通过事件或小组沟通来完成(我将向Ping工人实施经理节点,这也需要相同的动态协议),所以我考虑使用基于事件的架构的插座,但老师告诉我我更好使用REDIS或RABBITMQ使用间接通信。
问题是我真的不知道如何在python上实现redis消息侦听器,因为我只是找到的阻止示例,而true
则是redis.get_message()
大多数大多数时间(使用redis-py)。你能帮我吗?
非常感谢。
I am doing a master-worker architecture assignment with XMLRPC in Python and now I am supposed to implement a dynamic membership protocol so the workers list on the client gets updated everytime the master modifies it (worker added or deleted) so the client does not need to request it manually or before running a command.
The teacher mentioned it can be done through events or group communication (I will implement a manager node to ping workers which also needs the same dynamic protocol) so I thought about using sockets which is an event based architecture but the teacher told me I am better off using indirect communication with Redis or RabbitMQ.
The thing is I do not really know how to implement a Redis message listener on Python since I just find blocking examples with while True
followed by redis.get_message()
most of the time (using redis-py). Could you help me with that?
Thanks a lot in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了Redis的Discord Server上的Mephalich,我发现了一种有趣的方法,可以实现使用
run_in_thread
。Thanks to Mephalich on Redis' Discord server I discovered an interesting way to achieve that which consists of using
run_in_thread
.