def __init__(self, concurrency=None, loglevel=None, logfile=None, hostname=None, discard=False, run_clockservice=False, schedule=None, task_time_limit=None, task_soft_time_limit=None, max_tasks_per_child=None, queues=None, events=False, db=None, include=None, app=None, pidfile=None, redirect_stdouts=None, redirect_stdouts_level=None, autoscale=None, scheduler_cls=None, pool=None, **kwargs): self.app = app = app_or_default(app) self.concurrency = (concurrency or app.conf.CELERYD_CONCURRENCY or multiprocessing.cpu_count()) self.loglevel = loglevel or app.conf.CELERYD_LOG_LEVEL self.logfile = logfile or app.conf.CELERYD_LOG_FILE self.hostname = hostname or socket.gethostname() self.discard = discard self.run_clockservice = run_clockservice if self.app.IS_WINDOWS and self.run_clockservice: self.die("-B option does not work on Windows. " "Please run celerybeat as a separate service.") self.schedule = schedule or app.conf.CELERYBEAT_SCHEDULE_FILENAME self.scheduler_cls = scheduler_cls or app.conf.CELERYBEAT_SCHEDULER self.events = events self.task_time_limit = (task_time_limit or app.conf.CELERYD_TASK_TIME_LIMIT) self.task_soft_time_limit = (task_soft_time_limit or app.conf.CELERYD_TASK_SOFT_TIME_LIMIT) self.max_tasks_per_child = (max_tasks_per_child or app.conf.CELERYD_MAX_TASKS_PER_CHILD) self.redirect_stdouts = (redirect_stdouts or app.conf.CELERY_REDIRECT_STDOUTS) self.redirect_stdouts_level = (redirect_stdouts_level or app.conf.CELERY_REDIRECT_STDOUTS_LEVEL) self.pool = (pool or app.conf.CELERYD_POOL) self.db = db self.use_queues = queues or [] self.queues = None self.include = include or [] self.pidfile = pidfile self.autoscale = None if autoscale: max_c, _, min_c = partition(autoscale, ",") self.autoscale = [int(max_c), min_c and int(min_c) or 0] self._isatty = sys.stdout.isatty() self.colored = app.log.colored(self.logfile) if isinstance(self.use_queues, basestring): self.use_queues = self.use_queues.split(",") if isinstance(self.include, basestring): self.include = self.include.split(",") if not isinstance(self.loglevel, int): try: self.loglevel = LOG_LEVELS[self.loglevel.upper()] except KeyError: self.die("Unknown level %r. Please use one of %s." % ( self.loglevel, "|".join(l for l in LOG_LEVELS.keys() if isinstance(l, basestring))))
def __init__(self, concurrency=None, loglevel=None, logfile=None, hostname=None, discard=False, run_clockservice=False, schedule=None, task_time_limit=None, task_soft_time_limit=None, max_tasks_per_child=None, queues=None, events=False, db=None, include=None, defaults=None, pidfile=None, redirect_stdouts=None, redirect_stdouts_level=None, scheduler_cls=None, **kwargs): if defaults is None: from celery import conf defaults = conf self.defaults = defaults self.concurrency = (concurrency or defaults.CELERYD_CONCURRENCY or multiprocessing.cpu_count()) self.loglevel = loglevel or defaults.CELERYD_LOG_LEVEL self.logfile = logfile or defaults.CELERYD_LOG_FILE self.hostname = hostname or socket.gethostname() self.discard = discard self.run_clockservice = run_clockservice self.schedule = schedule or defaults.CELERYBEAT_SCHEDULE_FILENAME self.scheduler_cls = scheduler_cls or defaults.CELERYBEAT_SCHEDULER self.events = events self.task_time_limit = (task_time_limit or defaults.CELERYD_TASK_TIME_LIMIT) self.task_soft_time_limit = (task_soft_time_limit or defaults.CELERYD_TASK_SOFT_TIME_LIMIT) self.max_tasks_per_child = (max_tasks_per_child or defaults.CELERYD_MAX_TASKS_PER_CHILD) self.redirect_stdouts = (redirect_stdouts or defaults.REDIRECT_STDOUTS) self.redirect_stdouts_level = (redirect_stdouts_level or defaults.REDIRECT_STDOUTS_LEVEL) self.db = db self.queues = queues or [] self.include = include or [] self.pidfile = pidfile self._isatty = sys.stdout.isatty() self.colored = term.colored(enabled=defaults.CELERYD_LOG_COLOR) if isinstance(self.queues, basestring): self.queues = self.queues.split(",") if isinstance(self.include, basestring): self.include = self.include.split(",") if not isinstance(self.loglevel, int): try: self.loglevel = LOG_LEVELS[self.loglevel.upper()] except KeyError: self.die("Unknown level %r. Please use one of %s." % ( self.loglevel, "|".join(l for l in LOG_LEVELS.keys() if isinstance(l, basestring))))
def __init__(self, concurrency=None, loglevel=None, logfile=None, hostname=None, discard=False, run_clockservice=False, schedule=None, task_time_limit=None, task_soft_time_limit=None, max_tasks_per_child=None, queues=None, events=None, db=None, include=None, app=None, pidfile=None, redirect_stdouts=None, redirect_stdouts_level=None, autoscale=None, scheduler_cls=None, pool=None, **kwargs): self.app = app = app_or_default(app) conf = app.conf self.concurrency = (concurrency or conf.CELERYD_CONCURRENCY or cpu_count()) self.loglevel = loglevel or conf.CELERYD_LOG_LEVEL self.logfile = logfile or conf.CELERYD_LOG_FILE self.hostname = hostname or socket.gethostname() self.discard = discard self.run_clockservice = run_clockservice if self.app.IS_WINDOWS and self.run_clockservice: self.die("-B option does not work on Windows. " "Please run celerybeat as a separate service.") self.schedule = schedule or conf.CELERYBEAT_SCHEDULE_FILENAME self.scheduler_cls = scheduler_cls or conf.CELERYBEAT_SCHEDULER self.events = events if events is not None else conf.CELERY_SEND_EVENTS self.task_time_limit = (task_time_limit or conf.CELERYD_TASK_TIME_LIMIT) self.task_soft_time_limit = (task_soft_time_limit or conf.CELERYD_TASK_SOFT_TIME_LIMIT) self.max_tasks_per_child = (max_tasks_per_child or conf.CELERYD_MAX_TASKS_PER_CHILD) self.redirect_stdouts = (redirect_stdouts or conf.CELERY_REDIRECT_STDOUTS) self.redirect_stdouts_level = (redirect_stdouts_level or conf.CELERY_REDIRECT_STDOUTS_LEVEL) self.pool = pool or conf.CELERYD_POOL self.db = db self.use_queues = [] if queues is None else queues self.queues = None self.include = [] if include is None else include self.pidfile = pidfile self.autoscale = None if autoscale: max_c, _, min_c = autoscale.partition(",") self.autoscale = [int(max_c), min_c and int(min_c) or 0] self._isatty = sys.stdout.isatty() self.colored = app.log.colored(self.logfile) if isinstance(self.use_queues, basestring): self.use_queues = self.use_queues.split(",") if isinstance(self.include, basestring): self.include = self.include.split(",") if not isinstance(self.loglevel, int): try: self.loglevel = LOG_LEVELS[self.loglevel.upper()] except KeyError: self.die( "Unknown level %r. Please use one of %s." % (self.loglevel, "|".join(l for l in LOG_LEVELS.keys() if isinstance(l, basestring))))
def __init__(self, concurrency=None, loglevel=None, logfile=None, hostname=None, discard=False, run_clockservice=False, schedule=None, task_time_limit=None, task_soft_time_limit=None, max_tasks_per_child=None, queues=None, events=False, db=None, include=None, defaults=None, pidfile=None, redirect_stdouts=None, redirect_stdouts_level=None, scheduler_cls=None, **kwargs): if defaults is None: from celery import conf defaults = conf self.defaults = defaults self.concurrency = (concurrency or defaults.CELERYD_CONCURRENCY or multiprocessing.cpu_count()) self.loglevel = loglevel or defaults.CELERYD_LOG_LEVEL self.logfile = logfile or defaults.CELERYD_LOG_FILE self.hostname = hostname or socket.gethostname() self.discard = discard self.run_clockservice = run_clockservice self.schedule = schedule or defaults.CELERYBEAT_SCHEDULE_FILENAME self.scheduler_cls = scheduler_cls or defaults.CELERYBEAT_SCHEDULER self.events = events self.task_time_limit = (task_time_limit or defaults.CELERYD_TASK_TIME_LIMIT) self.task_soft_time_limit = (task_soft_time_limit or defaults.CELERYD_TASK_SOFT_TIME_LIMIT) self.max_tasks_per_child = (max_tasks_per_child or defaults.CELERYD_MAX_TASKS_PER_CHILD) self.redirect_stdouts = (redirect_stdouts or defaults.REDIRECT_STDOUTS) self.redirect_stdouts_level = (redirect_stdouts_level or defaults.REDIRECT_STDOUTS_LEVEL) self.db = db self.queues = queues or [] self.include = include or [] self.pidfile = pidfile self._isatty = sys.stdout.isatty() self.colored = term.colored(enabled=defaults.CELERYD_LOG_COLOR) if isinstance(self.queues, basestring): self.queues = self.queues.split(",") if isinstance(self.include, basestring): self.include = self.include.split(",") if not isinstance(self.loglevel, int): try: self.loglevel = LOG_LEVELS[self.loglevel.upper()] except KeyError: self.die( "Unknown level %r. Please use one of %s." % (self.loglevel, "|".join(l for l in LOG_LEVELS.keys() if isinstance(l, basestring))))