本文整理匯總了Python中celery.utils.log.get_task_logger方法的典型用法代碼示例。如果您正苦於以下問題:Python log.get_task_logger方法的具體用法?Python log.get_task_logger怎麽用?Python log.get_task_logger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類celery.utils.log
的用法示例。
在下文中一共展示了log.get_task_logger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_task
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def test_task():
from pylogctx import context
app = Celery(task_cls=LoggingTask)
@app.task
def my_task():
context.update(taskField='RUNNED')
logger = get_task_logger(current_task.name)
logger.info("I log!")
return context.as_dict()
result = my_task.apply()
if VERSION.major < 4:
result.maybe_reraise()
else:
result.maybe_throw()
fields = result.result
assert 'taskField' in fields
assert not context.as_dict()
示例2: test_old_task
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def test_old_task():
from pylogctx import context
app = Celery(task_cls=OldLoggingTask)
@app.task
def my_task():
logger = get_task_logger(current_task.name)
logger.info("I log!")
return context.as_dict()
result = my_task.apply()
if VERSION.major < 4:
result.maybe_reraise()
else:
result.maybe_throw()
fields = result.result
assert 'taskField' in fields
assert not context.as_dict()
示例3: __call__
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def __call__(self, *args, **kwargs):
self.logger = get_task_logger('que.mgmt')
task = 'MgmtTask %s%s' % (self.name, args[:2])
tidlock = kwargs.pop('tidlock', None)
check_user_tasks = kwargs.pop('check_user_tasks', False)
kwargs.pop('cache_result', None)
kwargs.pop('cache_timeout', None)
kwargs.pop('nolog', None)
tid = self.request.id
if tidlock:
task_lock = TaskLock(tidlock, desc=task, reverse_key=tid, logger=self.logger)
else:
task_lock = NoLock()
try:
if check_user_tasks: # Wait for task to appear in UserTasks - bug #chili-618
UserTasks.check(tid, logger=self.logger) # Will raise an exception in case the task does not show up
task_lock.task_check() # Will raise an exception in case the lock does not exist
return super(MgmtTask, self).__call__(tid, *args, **kwargs) # run()
finally:
task_lock.delete()
示例4: __init__
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def __init__(self, ps_client, es_client, array_context):
self._ps_client = ps_client;
self._es_client = es_client;
self._array_name = array_context.name
self._array_id = array_context.id
self._data_ttl = array_context.data_ttl
self.logger = get_task_logger(__name__)
示例5: delete_pipe
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def delete_pipe(pipe_id):
logger = get_task_logger(__name__)
logger.info("DELETED BY CELERY {}".format(pipe_id))
lostconfig = LOSTConfig()
dbm = DBMan(lostconfig)
pipeline.delete(dbm, pipe_id)
dbm.close_session()
示例6: send_life_sign
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def send_life_sign():
logger = get_task_logger(__name__)
lostconfig = LOSTConfig()
dbm = DBMan(lostconfig)
worker = dbm.get_worker(lostconfig.worker_name)
if worker is None:
register_worker(dbm, lostconfig)
logger.info('Registered worker: {}'.format(lostconfig.worker_name))
else:
worker.timestamp = datetime.utcnow()
dbm.add(worker)
dbm.commit()
#logger.info('Sent lifesign: {}'.format(worker.worker_name))
dbm.close_session()
示例7: __init__
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def __init__(self, dbm, pipe, lostconfig):
'''
:type dbm: lost.db.access.DBMan
:type pipe: lost.db.model.Pipe
'''
super().__init__(dbm=dbm, pipe=pipe)
self.lostconfig = lostconfig #type: lost.logic.config.LOSTConfig
self.file_man = FileMan(self.lostconfig)
# self.logger = lost.logic.log.get_file_logger(
# 'Executor: {}'.format(self.lostconfig.env),
# self.file_man.app_log_path)
self.logger = get_task_logger(__name__)
示例8: log
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def log(self):
return get_task_logger(self.name)
示例9: get_logger
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def get_logger(name):
logger = get_task_logger(name)
return logger
示例10: get_logger
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def get_logger(name):
""" Helper function to return a valid logger object
Args:
name (str): The name of the logger. Typically: __name__.
Returns:
Logger: A logger object for sending messages to the logging system
"""
return get_task_logger(name)
示例11: process_wechat_query_auth_code_test
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def process_wechat_query_auth_code_test(FromUserName, query_auth_code):
"""
處理發布前微信的自動化測試query_auth_code
"""
logger = get_task_logger('process_wechat_query_auth_code_test')
logger.info(FromUserName)
logger.info(query_auth_code)
component = get_component()
client = component.get_client_by_authorization_code(query_auth_code)
client.message.send_text(FromUserName, query_auth_code+'_from_api')
示例12: refresh_all_wechat_token
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def refresh_all_wechat_token(self):
"""
定時1小時,刷新所有已授權公眾號
"""
logger = get_task_logger('refresh_all_wechat_token')
for wechat in Wechat.objects.exclude(appid=settings.TEST_APPID).all():
if not wechat.authorized:
logger.error('公眾號{0}失去授權'.format(wechat.appid))
continue
refresh_wechat_token.delay(wechat.appid)
示例13: refresh_wechat_token
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def refresh_wechat_token(self, appid):
"""
刷新已授權公眾號
"""
logger = get_task_logger('refresh_wechat_token')
wechat = Wechat.objects.get(appid=appid)
if not wechat.authorized:
logger.error('公眾號{0}失去授權'.format(wechat.appid))
return None
try:
result = wechat.client.fetch_access_token()
logger.info(result)
except Exception as e:
logger.error(u'刷新已授權公眾號{0}失敗:{1}'.format(appid, str(e)))
示例14: log
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def log(self):
return get_task_logger("%s.%s" % (__name__, self.alert_name))
示例15: __call__
# 需要導入模塊: from celery.utils import log [as 別名]
# 或者: from celery.utils.log import get_task_logger [as 別名]
def __call__(self, cmd, *args, **kwargs):
self.logger = get_task_logger('que.tasks')
self.all_done = False
task = 'Task %s("%s")' % (self.name, cmd)
lock = kwargs.pop('lock', False)
block = kwargs.pop('block', None)
check_user_tasks = kwargs.pop('check_user_tasks', False)
tid = self.request.id
blocked = False
if lock:
task_lock = TaskLock(lock, desc=task, reverse_key=tid, logger=self.logger)
else:
task_lock = NoLock()
try:
if check_user_tasks: # Wait for task to appear in UserTasks - bug #chili-618
UserTasks.check(tid, logger=self.logger) # Will raise an exception in case the task does not show up
task_lock.task_check() # Will raise an exception in case the lock does not exist
if block and redis.exists(block):
blocked = True
self.retry(exc=TaskRetry(None)) # Will raise special exception
return super(MetaTask, self).__call__(cmd, *args, **kwargs) # run()
finally:
if not blocked: # Lock must _not_ be deleted when failing on retry
task_lock.delete()