def handle(self, *args, **options): if not options["task_code"]: log.error("Expected a task_code argument, use --help.") return numeric_level = getattr(logging, options["log_level"].upper(), None) if not isinstance(numeric_level, int): log.error("Invalid log level: %s" % options["log_level"]) numeric_level = 10 broker = BrokerConnection() connection = broker.connect_to_broker() removeFileHandlers() setFileHandler(options["worker_nr"]) setLevelToAllHandlers(numeric_level) if connection is None: log.error("Could not connect to broker.") return action = ActionTask(options["task_code"], options["worker_nr"]) logging.handlers.AMQPMessageHandler = AMQPMessageHandler broker_logging_handler = logging.handlers.AMQPMessageHandler( action, numeric_level) action.set_broker_logging_handler(broker_logging_handler) task_worker = Worker(connection, options["task_code"], action, options["worker_nr"]) task_worker.run_worker() removeFileHandlers()
def test_action(self, child, task_code, worker_nr): #action = ActionTask('120', '10') from flooding_worker.worker.worker import Worker from flooding_worker.worker.broker_connection import BrokerConnection connection = BrokerConnection().connect_to_broker() action = ActionTask(task_code, worker_nr) worker = Worker(connection, task_code, action, worker_nr) worker.run_worker()
def handle(self, *args, **options): broker = BrokerConnection() connection = broker.connect_to_broker() removeFileHandlers() setFileHandler('logging') if connection is None: log.error("Could not connect to broker.") return action = ActionLogging() logging_worker = Worker(connection, options["task_code"], action) logging_worker.run_worker()
def handle(self, *args, **options): numeric_level = getattr(logging, options["log_level"].upper(), None) if not isinstance(numeric_level, int): log.error("Invalid log level: %s" % options["log_level"]) numeric_level = 10 broker = BrokerConnection() connection = broker.connect_to_broker() removeFileHandlers() setFileHandler('queue') if connection is None: log.error("Could not connect to broker.") return # TODO CREATE ActionPreority action = ActionPriority(connection, options["task_code"]) queue_worker = Worker(connection, options["task_code"], action) queue_worker.run_worker()