当前位置: 首页>>代码示例>>Python>>正文


Python worker_process_init.connect方法代码示例

本文整理汇总了Python中celery.signals.worker_process_init.connect方法的典型用法代码示例。如果您正苦于以下问题:Python worker_process_init.connect方法的具体用法?Python worker_process_init.connect怎么用?Python worker_process_init.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在celery.signals.worker_process_init的用法示例。


在下文中一共展示了worker_process_init.connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect_mongo

# 需要导入模块: from celery.signals import worker_process_init [as 别名]
# 或者: from celery.signals.worker_process_init import connect [as 别名]
def connect_mongo(**kwargs):
    """Connect to mongo and load modules in each worker process."""
    from core.config import celeryimports
    from core.yeti_plugins import get_plugins
    connect(
        yeti_config.mongodb.database,
        host=yeti_config.mongodb.host,
        port=yeti_config.mongodb.port,
        username=yeti_config.mongodb.username,
        password=yeti_config.mongodb.password,
        connect=False)
    celeryimports.loaded_modules = get_plugins() 
开发者ID:yeti-platform,项目名称:yeti,代码行数:14,代码来源:celeryctl.py

示例2: init_app

# 需要导入模块: from celery.signals import worker_process_init [as 别名]
# 或者: from celery.signals.worker_process_init import connect [as 别名]
def init_app(self, app):
        self.app = app
        new_celery = celery.Celery(
            app.import_name,
            broker=app.config["CELERY_BROKER_URL"],
            backend=app.config["CELERY_RESULT_BACKEND"],
        )
        # XXX(dcramer): why the hell am I wasting time trying to make Celery work?
        self.celery.__dict__.update(vars(new_celery))
        self.celery.conf.update(app.config)

        worker_process_init.connect(self._worker_process_init)

        task_postrun.connect(self._task_postrun)
        task_prerun.connect(self._task_prerun) 
开发者ID:getsentry,项目名称:zeus,代码行数:17,代码来源:celery.py

示例3: cleanup_dead_jobs

# 需要导入模块: from celery.signals import worker_process_init [as 别名]
# 或者: from celery.signals.worker_process_init import connect [as 别名]
def cleanup_dead_jobs():
    """
    This cleans up jobs that have been marked as ran, but are not queue'd in celery. It is meant
    to cleanup jobs that have been lost due to a server crash or some other reason a job is
    in limbo.
    """
    from .models import WooeyJob

    # Get active tasks from Celery
    inspect = celery_app.control.inspect()
    worker_info = inspect.active()

    # If we cannot connect to the workers, we do not know if the tasks are running or not, so
    # we cannot mark them as dead
    if not worker_info:
        return

    active_tasks = {task['id'] for worker, tasks in six.iteritems(worker_info) for task in tasks}

    # find jobs that are marked as running but not present in celery's active tasks
    active_jobs = WooeyJob.objects.filter(status=WooeyJob.RUNNING)
    to_disable = set()
    for job in active_jobs:
        if job.celery_id not in active_tasks:
            to_disable.add(job.pk)

    WooeyJob.objects.filter(pk__in=to_disable).update(status=WooeyJob.FAILED) 
开发者ID:wooey,项目名称:Wooey,代码行数:29,代码来源:tasks.py


注:本文中的celery.signals.worker_process_init.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。