17 lines
		
	
	
		
			424 B
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			424 B
		
	
	
	
		
			Python
		
	
	
	
# from __future__ import absolute_import, unicode_literals
 | 
						|
from celery import Task
 | 
						|
import logging
 | 
						|
 | 
						|
# 实例化myLogger
 | 
						|
myLogger = logging.getLogger('log')
 | 
						|
 | 
						|
 | 
						|
class CustomTask(Task):
 | 
						|
    """
 | 
						|
    自定义的任务回调
 | 
						|
    """
 | 
						|
 | 
						|
    def on_failure(self, exc, task_id, args, kwargs, einfo):
 | 
						|
        myLogger.error('{0!r} failed: {1!r}'.format(task_id, exc))
 | 
						|
        return super().on_failure(exc, task_id, args, kwargs, einfo)
 |