rpc_producer.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:py3_project 作者: tjy-cool 项目源码 文件源码
def run(self, input_cmd):

        body = input_cmd.split("run \"")[1].split("\" ")[0]
        hosts = input_cmd.split("--hosts")[1].strip().split(" ")
        for host_ip in hosts:
            if self.judge_legal_ip(host_ip):        # ??IP??????
                '''
                self.connections = {
                    host_ip1:{
                        'connection': pika.BlockingConnection(),
                        'channel': Channel1,
                        'callback_queue': result.method.queue
                    },
                    host_ip2:{
                        'connection': pika.BlockingConnection(),
                        'channel': Channel2,
                        'callback_queue': result.method.queue
                    }
                }
                '''
                print("IP [%s] is Legal ip" % host)
                conn_info = {}

                conn_info['connection'] = pika.BlockingConnection(
                    pika.ConnectionParameters(host=host))
                conn_info['channel'] = conn_info['connection'].channel(
                )
                result = self.channel.queue_declare(exclusive=True)
                conn_info['callback_queue'] = result.method.queue
                conn_info['channel'].basic_consume(
                    self.on_response, no_ack=True, queue=conn_info['callback_queue'])

                conn_info['response'] = None
                self.connections[host_ip] = conn_info
            else:
                print("IP [%s] is Illegal ip" % host_ip)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号