本文整理匯總了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
示例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
示例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
示例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)