示例#1
0
    def run(self):
        """Event cycle."""

        config = Configs.instance()
        LOG.debug("create connection")
        self.connection = pika.BlockingConnection(config.amqp_params)
        LOG.debug("Bureaucrat connected")
        self.channel = self.connection.channel()
        self.schedule = Schedule(ChannelWrapper(self.channel))
        self.channel.queue_declare(queue="bureaucrat",
                                   durable=True,
                                   exclusive=False,
                                   auto_delete=False)
        self.channel.queue_declare(queue=config.message_queue,
                                   durable=True,
                                   exclusive=False,
                                   auto_delete=False)
        self.channel.queue_declare(queue=config.event_queue,
                                   durable=True,
                                   exclusive=False,
                                   auto_delete=False)
        self.channel.queue_declare(queue="bureaucrat_schedule",
                                   durable=True,
                                   exclusive=False,
                                   auto_delete=False)
        self.channel.basic_qos(prefetch_count=1)
        self.channel.basic_consume("bureaucrat", self.launch_process)
        self.channel.basic_consume(config.message_queue, self.handle_message)
        self.channel.basic_consume(config.event_queue, self.handle_event)
        self.channel.basic_consume("bureaucrat_schedule", self.add_schedule)
        signal.signal(signal.SIGALRM, self.handle_alarm)
        signal.setitimer(signal.ITIMER_REAL, 60, 60)
        self.channel.start_consuming()
示例#2
0
 def setUp(self):
     """Set up SUT."""
     confparser = ConfigParser()
     confparser.add_section('bureaucrat')
     confparser.set('bureaucrat', 'storage_dir', STORAGE_DIR)
     Configs.instance(confparser)
     Storage.instance()
     self.ch = Mock()
     self.schedule = Schedule(self.ch)