slave.py 文件源码

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

项目:rebus 作者: airbus-seclab 项目源码 文件源码
def __init__(self, options):
        Bus.__init__(self)
        busaddr = options.rabbitaddr

        # Connects to the rabbitmq server
        busaddr += "/%2F?connection_attempts=200&heartbeat_interval=" +\
            str(options.heartbeat)
        self.busaddr = busaddr
        params = pika.URLParameters(busaddr)
        log.info("Connecting to rabbitmq server at: " + str(busaddr))
        b = False
        while not b:
            try:
                self.connection = pika.BlockingConnection(params)
                b = True
            except pika.exceptions.ConnectionClosed:
                log.warning("Cannot connect to rabbitmq at: " + str(busaddr) +
                            ". Retrying..")
                time.sleep(0.5)
            # TODO: quit here (failed to connect)

        self.channel = self.connection.channel()

        signal.signal(signal.SIGTERM, self.sigterm_handler)

        #: Contains agent instance. This Bus implementation accepts only one
        #: agent. Agent must be run using separate RabbitBus() (bus slave)
        #: instances.
        self.agent = None
        self.main_thread_id = thread.get_ident()

    # TODO: check if key exists
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号