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


Python current_app._get_current_object方法代码示例

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


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

示例1: __init__

# 需要导入模块: from celery import current_app [as 别名]
# 或者: from celery.current_app import _get_current_object [as 别名]
def __init__(self, model):
        self.app = current_app._get_current_object()
        self.name = model.name
        self.task = model.task
        self.schedule = model.schedule
        self.args = model.args
        self.kwargs = model.kwargs
        self.options = dict(
            queue=model.queue,
            exchange=model.exchange,
            routing_key=model.routing_key,
            expires=model.expires,
        )
        self.total_run_count = model.total_run_count
        self.model = model

        if not model.last_run_at:
            model.last_run_at = self._default_now()
        orig = self.last_run_at = model.last_run_at
        if not is_naive(self.last_run_at):
            self.last_run_at = self.last_run_at.replace(tzinfo=None)
        assert orig.hour == self.last_run_at.hour  # timezone sanity 
开发者ID:tuomur,项目名称:celery_sqlalchemy_scheduler,代码行数:24,代码来源:sqlalchemy_scheduler.py

示例2: __init__

# 需要导入模块: from celery import current_app [as 别名]
# 或者: from celery.current_app import _get_current_object [as 别名]
def __init__(self, task):
        self._task = task

        self.app = current_app._get_current_object()
        self.name = self._task.name
        self.task = self._task.task

        self.enabled = self._task.enabled
        self.schedule_str = self._task.schedule_str
        self.schedule_type = self._task.schedule_type
        self.schedule = self._task.schedule

        self.args = self._task.args
        self.kwargs = self._task.kwargs
        self.options = {
            'queue': self._task.queue,
            'exchange': self._task.exchange,
            'routing_key': self._task.routing_key,
            'expires': self._task.expires
        }
        if self._task.total_run_count is None:
            self._task.total_run_count = 0
        self.total_run_count = self._task.total_run_count

        if not self._task.last_run_at:
            self.last_run_at = self._default_now()
        else:
            self.last_run_at = self._task.last_run_at 
开发者ID:mozilla,项目名称:MozDef,代码行数:30,代码来源:alert_schedule_entry.py

示例3: __init__

# 需要导入模块: from celery import current_app [as 别名]
# 或者: from celery.current_app import _get_current_object [as 别名]
def __init__(self, task):
        self._task = task

        self.app = current_app._get_current_object()
        self.name = self._task.name
        self.task = self._task.task

        self.schedule = self._task.schedule

        self.args = self._task.args
        self.kwargs = self._task.kwargs
        self.options = {
            'queue': self._task.queue,
            'exchange': self._task.exchange,
            'routing_key': self._task.routing_key,
            'expires': self._task.expires,
            'soft_time_limit': self._task.soft_time_limit,
            'enabled': self._task.enabled
        }
        if self._task.total_run_count is None:
            self._task.total_run_count = 0
        self.total_run_count = self._task.total_run_count

        if not self._task.last_run_at:
            self._task.last_run_at = self._default_now()
        self.last_run_at = self._task.last_run_at 
开发者ID:zmap,项目名称:celerybeat-mongo,代码行数:28,代码来源:schedulers.py

示例4: __init__

# 需要导入模块: from celery import current_app [as 别名]
# 或者: from celery.current_app import _get_current_object [as 别名]
def __init__(self, model, Session, app=None, **kw):
        """Initialize the model entry."""
        self.app = app or current_app._get_current_object()
        self.session = kw.get('session')
        self.Session = Session

        self.model = model
        self.name = model.name
        self.task = model.task

        try:
            self.schedule = model.schedule
            logger.debug('schedule: {}'.format(self.schedule))
        except Exception as e:
            logger.error(e)
            logger.error(
                'Disabling schedule %s that was removed from database',
                self.name,
            )
            self._disable(model)

        try:
            self.args = loads(model.args or '[]')
            self.kwargs = loads(model.kwargs or '{}')
        except ValueError as exc:
            logger.exception(
                'Removing schedule %s for argument deseralization error: %r',
                self.name, exc,
            )
            self._disable(model)

        self.options = {}
        for option in ['queue', 'exchange', 'routing_key', 'expires',
                       'priority']:
            value = getattr(model, option)
            if value is None:
                continue
            self.options[option] = value

        self.total_run_count = model.total_run_count
        self.enabled = model.enabled

        if not model.last_run_at:
            model.last_run_at = self._default_now()
        self.last_run_at = model.last_run_at

        # 因为从数据库读取的 last_run_at 可能没有时区信息,所以这里必须加上时区信息
        # self.last_run_at = self.last_run_at.replace(tzinfo=self.app.timezone)

        # self.options['expires'] 同理
        # if 'expires' in self.options:
        #     expires = self.options['expires']
        #     self.options['expires'] = expires.replace(tzinfo=self.app.timezone) 
开发者ID:AngelLiang,项目名称:celery-sqlalchemy-scheduler,代码行数:55,代码来源:schedulers.py


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