当前位置: 首页>>代码示例>>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;未经允许,请勿转载。