コード例 #1
0
ファイル: djangohuey.py プロジェクト: gaiacoop/django-huey
    def add_arguments(self, parser):
        option_handler = OptionParserHandler()
        groups = (
            option_handler.get_logging_options(),
            option_handler.get_worker_options(),
            option_handler.get_scheduler_options(),
        )
        for option_list in groups:
            for short, full, kwargs in option_list:
                if short == "-v":
                    full = "--huey-verbose"
                    short = "-V"
                if "type" in kwargs:
                    kwargs["type"] = self._type_map[kwargs["type"]]
                kwargs.setdefault("default", None)
                parser.add_argument(full, short, **kwargs)

        parser.add_argument(
            "-A",
            "--disable-autoload",
            action="store_true",
            dest="disable_autoload",
            help='Do not autoload "tasks.py"',
        )
        parser.add_argument(
            "--queue",
            action="store",
            dest="queue",
            help="Name of the queue consumer to run",
        )
コード例 #2
0
ファイル: run_huey.py プロジェクト: anentropic/huey
 def add_arguments(self, parser):
     option_handler = OptionParserHandler()
     groups = (
         option_handler.get_logging_options(),
         option_handler.get_worker_options(),
         option_handler.get_scheduler_options(),
     )
     for option_list in groups:
         for short, full, kwargs in option_list:
             if short == '-v':
                 full = '--huey-verbose'
                 short = '-V'
             if 'type' in kwargs:
                 kwargs['type'] = self._type_map[kwargs['type']]
             parser.add_argument(full, short, **kwargs)
コード例 #3
0
 def add_arguments(self, parser):
     option_handler = OptionParserHandler()
     groups = (
         option_handler.get_logging_options(),
         option_handler.get_worker_options(),
         option_handler.get_scheduler_options(),
     )
     for option_list in groups:
         for short, full, kwargs in option_list:
             if short == '-v':
                 full = '--huey-verbose'
                 short = '-V'
             if 'type' in kwargs:
                 kwargs['type'] = self._type_map[kwargs['type']]
             parser.add_argument(full, short, **kwargs)
コード例 #4
0
def main():
    os.nice(10)
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()
    options = {k: v for k, v in options.__dict__.items()
           if v is not None}
    defaultConf = {'workers': workers, 'worker_type': 'process'}
    config = ConsumerConfig(**collections.ChainMap(options,defaultConf))
    config.validate()

    huey_instance = load_class("lcars.settings.HUEY")

    logger = logging.getLogger('huey')
    config.setup_logger(logger)
    consumer =  huey_instance.create_consumer(**config.values)
    consumer.run()
コード例 #5
0
ファイル: huey_consumer.py プロジェクト: simonwahlgren/huey
def consumer_main():
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()

    if len(args) == 0:
        err('Error:   missing import path to `Huey` instance')
        err('Example: huey_consumer.py app.queue.huey_instance')
        sys.exit(1)

    config = ConsumerConfig(**options.__dict__)
    config.validate()

    huey_instance = load_huey(args[0])
    config.setup_logger()

    consumer = Consumer(huey_instance, **config.values)
    consumer.run()
コード例 #6
0
ファイル: run_huey.py プロジェクト: yijxiang/huey
    def add_arguments(self, parser):
        option_handler = OptionParserHandler()
        groups = (
            option_handler.get_logging_options(),
            option_handler.get_worker_options(),
            option_handler.get_scheduler_options(),
        )
        for option_list in groups:
            for short, full, kwargs in option_list:
                if short == '-v':
                    full = '--huey-verbose'
                    short = '-V'
                if 'type' in kwargs:
                    kwargs['type'] = self._type_map[kwargs['type']]
                kwargs.setdefault('default', None)
                parser.add_argument(full, short, **kwargs)

        parser.add_argument('-A', '--disable-autoload', action='store_true',
                            dest='disable_autoload',
                            help='Do not autoload "tasks.py"')
コード例 #7
0
def start_consumer(workers, worker_type, scheduler_interval, enable_verbose):
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()

    options = {k: v for k, v in options.__dict__.items() if v is not None}
    options["workers"] = workers
    options["worker-type"] = worker_type
    options["scheduler-interval"] = scheduler_interval

    if enable_verbose:
        options["verbose"] = ""

    config = ConsumerConfig(**options)
    config.validate()

    config.setup_logger()

    consumer = huey_queue.create_consumer(**config.values)
    consumer.run()
コード例 #8
0
ファイル: run_huey.py プロジェクト: coleifer/huey
    def add_arguments(self, parser):
        option_handler = OptionParserHandler()
        groups = (
            option_handler.get_logging_options(),
            option_handler.get_worker_options(),
            option_handler.get_scheduler_options(),
        )
        for option_list in groups:
            for short, full, kwargs in option_list:
                if short == '-v':
                    full = '--huey-verbose'
                    short = '-V'
                if 'type' in kwargs:
                    kwargs['type'] = self._type_map[kwargs['type']]
                kwargs.setdefault('default', None)
                parser.add_argument(full, short, **kwargs)

        parser.add_argument('-A', '--disable-autoload', action='store_true',
                            dest='disable_autoload',
                            help='Do not autoload "tasks.py"')
コード例 #9
0
def consumer_main():
    parser_handler = OptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()

    if len(args) == 0:
        err('Error:   missing import path to `Huey` instance')
        err('Example: huey_consumer.py app.queue.huey_instance')
        sys.exit(1)

    options = {k: v for k, v in options.__dict__.items() if v is not None}
    config = ConsumerConfig(**options)
    config.validate()

    huey_instance = load_huey(args[0])

    # Set up logging for the "huey" namespace.
    logger = logging.getLogger('huey')
    config.setup_logger(logger)

    consumer = huey_instance.create_consumer(**config.values)
    consumer.run()