예제 #1
0
    def __init__(self):
        self.gateway_manager = GatewayManager()

        self.sms_queue = 'sms_queue'
        self.sms_exchange = 'sms_exchange'
        # self.requeue_ids = current.myconf.take('')

        # This channel created for adding sms to queue
        sms_producer_channel = self.__create_channel(
            queue=self.sms_queue, exchange=self.sms_exchange)
        self.sms_producer_channel = sms_producer_channel

        # This channel created for consuming sent sms
        sms_consumer_channel = self.__create_channel(
            queue=self.sms_queue, exchange=self.sms_exchange)
        sms_consumer_channel.basic_consume(self.__sms_callback,
                                           queue=self.sms_queue)

        thread = Thread(target=self.sms_consumer_loop,
                        args=(sms_consumer_channel, ))
        thread.start()