logging.disable(loglevel) # Restore workaround if channel is None: raise RuntimeError( 'Could not connect to any available RabbitMQ endpoint.') logger.debug('Connected to: {0}'.format(server)) queue = sys.argv[1] if len(sys.argv) == 2 else 'default' channel.queue_declare(queue=queue, durable=True) logger.info('Waiting for messages on {0}...'.format(queue), print_msg=True) logger.info('To exit press CTRL+C', print_msg=True) channel.basic_qos(prefetch_count=1) channel.basic_consume(callback, queue=queue) channel.start_consuming() else: # We need to keep the process running logger.info('To exit press CTRL+C', print_msg=True) while True: time.sleep(3600) except KeyboardInterrupt: if run_kvm_watcher() and notifier is not None: notifier.stop() except Exception as exception: logger.error('Unexpected exception: {0}'.format(str(exception)), print_msg=True) if run_kvm_watcher() and notifier is not None: notifier.stop() sys.exit(1)
break except: pass logging.disable(loglevel) # Restore workaround if channel is None: raise RuntimeError("Could not connect to any available RabbitMQ endpoint.") logger.debug("Connected to: {0}".format(server)) queue = sys.argv[1] if len(sys.argv) == 2 else "default" channel.queue_declare(queue=queue, durable=True) logger.info("Waiting for messages on {0}...".format(queue), print_msg=True) logger.info("To exit press CTRL+C", print_msg=True) channel.basic_qos(prefetch_count=1) channel.basic_consume(callback, queue=queue) channel.start_consuming() else: # We need to keep the process running logger.info("To exit press CTRL+C", print_msg=True) while True: time.sleep(3600) except KeyboardInterrupt: if run_kvm_watcher() and notifier is not None: notifier.stop() except Exception as exception: logger.error("Unexpected exception: {0}".format(str(exception)), print_msg=True) if run_kvm_watcher() and notifier is not None: notifier.stop() sys.exit(1)