當前位置: 首頁>>代碼示例>>Python>>正文


Python schedules.crontab方法代碼示例

本文整理匯總了Python中celery.schedules.crontab方法的典型用法代碼示例。如果您正苦於以下問題:Python schedules.crontab方法的具體用法?Python schedules.crontab怎麽用?Python schedules.crontab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在celery.schedules的用法示例。


在下文中一共展示了schedules.crontab方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _unpack_fields

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def _unpack_fields(cls, session, schedule,
                       args=None, kwargs=None, relative=None, options=None,
                       **entry):
        """

        **entry sample:

            {'task': 'celery.backend_cleanup',
             'schedule': <crontab: 0 4 * * * (m/h/d/dM/MY)>,
             'options': {'expires': 43200}}

        """
        model_schedule, model_field = cls.to_model_schedule(session, schedule)
        entry.update(
            # the model_id which to relationship
            {model_field + '_id': model_schedule.id},
            args=dumps(args or []),
            kwargs=dumps(kwargs or {}),
            **cls._unpack_options(**options or {})
        )
        return entry 
開發者ID:AngelLiang,項目名稱:celery-sqlalchemy-scheduler,代碼行數:23,代碼來源:schedulers.py

示例2: decode_schedule

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def decode_schedule(obj):
    if obj is None:
        return None

    _type = obj['__type__']
    value = obj['__value__']

    if _type == 'datetime':
        return decode_datetime(value)
    elif _type == 'crontab':
        return crontab(*value.split('\t'))
    elif _type == 'solar':
        return solar(**value)
    elif _type == 'schedule':
        return schedule(**value)
    else:
        raise NotImplementedError(
            'Cannot deserialize schedule %(type)s type' % {
                'type': _type
            }
        ) 
開發者ID:mixkorshun,項目名稱:celery-beatx,代碼行數:23,代碼來源:serializer.py

示例3: update_from_dict

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def update_from_dict(self, mapping):
        s = {}
        for name, entry_fields in items(mapping):
            # {'task': 'celery.backend_cleanup',
            #  'schedule': schedules.crontab('0', '4', '*'),
            #  'options': {'expires': 43200}}
            try:
                entry = self.Entry.from_entry(
                    name, Session=self.Session, app=self.app,
                    **entry_fields)
                if entry.model.enabled:
                    s[name] = entry
            except Exception as exc:
                logger.error(ADD_ENTRY_ERROR, name, exc, entry_fields)

        # update self.schedule
        self.schedule.update(s) 
開發者ID:AngelLiang,項目名稱:celery-sqlalchemy-scheduler,代碼行數:19,代碼來源:schedulers.py

示例4: test_parsing_dict

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def test_parsing_dict(self):
        task = PeriodicTask(**self.task_dict)
        assert task.name == 'bruteforce_ssh.AlertBruteforceSsh'
        assert task.task == 'bruteforce_ssh.AlertBruteforceSsh'
        assert task.args == []
        assert task.kwargs == {}
        assert task.enabled is True
        assert task.queue is None
        assert task.exchange is None
        assert task.routing_key is None
        assert task.last_run_at is None
        assert task.run_immediately is False
        assert task.total_run_count is 0
        assert task.schedule_type == 'crontab'
        assert task.schedule_str == '0 5 * * *'
        assert isinstance(task.celery_schedule, Crontab) is True
        assert isinstance(task.schedule, celery_crontab) is True 
開發者ID:mozilla,項目名稱:MozDef,代碼行數:19,代碼來源:test_periodic_task.py

示例5: update_celerybeat_schedule

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def update_celerybeat_schedule(celerybeat_schedule_settings, figures_env_tokens):
    """
    Figures pipeline job schedule configuration in CELERYBEAT_SCHEDULE.

    Daily metrics pipeline scheduler is on by default
    Course MAU metrics pipeline scheduler is off by default

    TODO: Language improvement: Change the "IMPORT" to "CAPTURE" or "EXTRACT"
    """
    if figures_env_tokens.get('ENABLE_DAILY_METRICS_IMPORT', True):
        celerybeat_schedule_settings['figures-populate-daily-metrics'] = {
            'task': 'figures.tasks.populate_daily_metrics',
            'schedule': crontab(
                hour=figures_env_tokens.get('DAILY_METRICS_IMPORT_HOUR', 2),
                minute=figures_env_tokens.get('DAILY_METRICS_IMPORT_MINUTE', 0),
                ),
            }

    if figures_env_tokens.get('ENABLE_DAILY_MAU_IMPORT', False):
        celerybeat_schedule_settings['figures-daily-mau'] = {
            'task': 'figures.tasks.populate_all_mau',
            'schedule': crontab(
                hour=figures_env_tokens.get('DAILY_MAU_IMPORT_HOUR', 0),
                minute=figures_env_tokens.get('DAILY_MAU_IMPORT_MINUTE', 0),
                ),
            }

    if figures_env_tokens.get('ENABLE_FIGURES_MONTHLY_METRICS', False):
        celerybeat_schedule_settings['figures-monthly-metrics'] = {
            'task': 'figures.tasks.run_figures_monthly_metrics',
            'schedule': crontab(0, 0, day_of_month=1),
            } 
開發者ID:appsembler,項目名稱:figures,代碼行數:34,代碼來源:lms_production.py

示例6: schedule

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def schedule(self):
        return schedules.crontab(minute=self.minute,
                                 hour=self.hour,
                                 day_of_week=self.day_of_week,
                                 day_of_month=self.day_of_month,
                                 month_of_year=self.month_of_year) 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:8,代碼來源:celery.py

示例7: __str__

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def __str__(self):
        fmt = '{0.name}: {0.crontab}'
        return fmt.format(self) 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:5,代碼來源:celery.py

示例8: install_default_entries

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def install_default_entries(self, data):
        entries = {}
        if self.app.conf.CELERY_TASK_RESULT_EXPIRES:
            entries.setdefault(
                'celery.backend_cleanup', {
                    'task': 'celery.backend_cleanup',
                    'schedule': schedules.crontab('*/5', '*', '*'),
                    'options': {'expires': 12 * 3600},
                },
            )
        self.update_from_dict(entries) 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:13,代碼來源:schedulers.py

示例9: create_app

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def create_app(debug=False):
    """Create an application context with blueprints."""
    app = Flask(__name__, static_folder='./resources')
    app.config['SECRET_KEY'] = 'RYVl4Fg3n1JLDaxWyr1m'
    app.config['MONGO_DBNAME'] = 'chirp'
    app.config['USERS_COLLECTION'] = 'accounts'
    app.config['MONITORS_COLLECTION'] = 'monitors'
    app.config['ARTICLES_COLLECTION'] = 'articles'
    app.config['GLOBAL_COLLECTION'] = 'global'
    login_manager.init_app(app)
    mongo.init_app(app)
    app.config.update(
        BROKER_TRANSPORT_OPTIONS={'visibility_timeout': 3600},
        CELERY_BROKER_URL='redis://localhost:6379',
        CELERY_RESULT_BACKEND='redis://localhost:6379',
        CELERYBEAT_SCHEDULE={
            # 'heartbeat': {
            #     'task': 'heartbeat',
            #     'schedule': crontab(minute='*')
            # },
            'process_all_rss': {
                'task': 'process_all_rss',
                'schedule': crontab(minute='*/15')
            }
        }
    )
    celery.conf.update(app.config)

    from .core import core as core_blueprint
    app.register_blueprint(core_blueprint)
    app.register_error_handler(404, page_not_found)
    app.register_error_handler(500, server_error)

    return app 
開發者ID:9b,項目名稱:chirp,代碼行數:36,代碼來源:__init__.py

示例10: from_entry

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def from_entry(cls, name, Session, app=None, **entry):
        """

        **entry sample:

            {'task': 'celery.backend_cleanup',
             'schedule': schedules.crontab('0', '4', '*'),
             'options': {'expires': 43200}}

        """
        session = Session()
        with session_cleanup(session):
            periodic_task = session.query(
                PeriodicTask).filter_by(name=name).first()
            if not periodic_task:
                periodic_task = PeriodicTask(name=name)
            temp = cls._unpack_fields(session, **entry)
            periodic_task.update(**temp)
            session.add(periodic_task)
            try:
                session.commit()
            except sqlalchemy.exc.IntegrityError as exc:
                logger.error(exc)
                session.rollback()
            except Exception as exc:
                logger.error(exc)
                session.rollback()
            res = cls(periodic_task, app=app, Session=Session, session=session)
            return res 
開發者ID:AngelLiang,項目名稱:celery-sqlalchemy-scheduler,代碼行數:31,代碼來源:schedulers.py

示例11: install_default_entries

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def install_default_entries(self, data):
        entries = {}
        if self.app.conf.result_expires:
            entries.setdefault(
                'celery.backend_cleanup', {
                    'task': 'celery.backend_cleanup',
                    'schedule': schedules.crontab('0', '4', '*'),
                    'options': {'expires': 12 * 3600},
                },
            )
        self.update_from_dict(entries) 
開發者ID:AngelLiang,項目名稱:celery-sqlalchemy-scheduler,代碼行數:13,代碼來源:schedulers.py

示例12: __repr__

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def __repr__(self):
        return """<crontab: {0._orig_minute} {0._orig_hour} \
{0._orig_day_of_week} {0._orig_day_of_month} \
{0._orig_month_of_year} (m/h/d/dM/MY), {0.tz}>""".format(self) 
開發者ID:AngelLiang,項目名稱:celery-sqlalchemy-scheduler,代碼行數:6,代碼來源:tzcrontab.py

示例13: run_django_management_command

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def run_django_management_command(self, command, *args, **kwargs):
    management.call_command(command, *args, **kwargs)


# Configure periodic tasks here
# This task is not needed anymore (number of ground truth annotations per taxonomy node is real time:
# updated at each generation of ground truth)
# However this can serve as an example for possibly future periodic tasks.
# @app.on_after_configure.connect
# def setup_periodic_tasks(sender, **kwargs):
#     sender.add_periodic_task(
#         crontab(hour="*", minute="*/15"),
#         run_django_management_command.s('compute_priority_score_taxonomy_node'),
#         name='compute priority score taxonomy node'
#     ) 
開發者ID:MTG,項目名稱:freesound-datasets,代碼行數:17,代碼來源:celery.py

示例14: start_stacking_scheduler

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def start_stacking_scheduler():
    logger.info('Entered entrypoint to celery beat scheduling')
    runtime_context = parse_args(settings)
    for site, entry in runtime_context.SCHEDULE_STACKING_CRON_ENTRIES.items():
        app.add_periodic_task(crontab(minute=entry['minute'], hour=entry['hour']),
                              schedule_calibration_stacking.s(site=site, runtime_context=vars(runtime_context)))

    beat = celery.bin.beat.beat(app=app)
    logger.info('Starting celery beat')
    beat.run() 
開發者ID:LCOGT,項目名稱:banzai,代碼行數:12,代碼來源:main.py

示例15: get_schedule

# 需要導入模塊: from celery import schedules [as 別名]
# 或者: from celery.schedules import crontab [as 別名]
def get_schedule(self) -> Any:
        if self.type == "CRONTAB":
            return crontab(**self.crontab_kwargs)
        return float(self.schedule) 
開發者ID:vstconsulting,項目名稱:polemarch,代碼行數:6,代碼來源:tasks.py


注:本文中的celery.schedules.crontab方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。