示例#1
0
 def format(self, record):  # noqa: A003
     task = current_task()
     if task and task.request:
         self._fmt = self._task
         record.__dict__.update(
             taskid=task.request.id,
             taskname=task.name,
         )
     else:
         self._fmt = self._base
     return super(TaskFormatter, self).format(record)
示例#2
0
    def __call__(self, *args, **kwargs):
        task = current_task()

        try:
            context.update(task)
        except Exception as e:
            logger.debug('Failed to push task to log context: %r', e)

        try:
            return super(LoggingTask, self).__call__(*args, **kwargs)
        finally:
            context.clear()
示例#3
0
文件: sets.py 项目: psnj/celery
    def apply_async(self, connection=None, connect_timeout=None, publisher=None, taskset_id=None):
        """Apply group."""
        app = self.app

        if app.conf.CELERY_ALWAYS_EAGER:
            return self.apply(taskset_id=taskset_id)

        with app.default_connection(connection, connect_timeout) as conn:
            setid = taskset_id or uuid()
            pub = publisher or self.Publisher(connection=conn)
            try:
                results = self._async_results(setid, pub)
            finally:
                if not publisher:  # created by us.
                    pub.close()

            result = app.TaskSetResult(setid, results)
            parent = current_task()
            if parent:
                parent.request.children.append(result)
            return result
示例#4
0
 def my_task():
     context.update(taskField='RUNNED')
     logger = get_task_logger(current_task().name)
     logger.info("I log!")
     return context.as_dict()
示例#5
0
文件: base.py 项目: JonPeel/celery
 def current_task_children(self):
     current = current_task()
     if current:
         return [r.serializable() for r in current.request.children]
示例#6
0
文件: base.py 项目: lican09/celery
 def current_task_children(self, request=None):
     request = request or getattr(current_task(), 'request', None)
     if request:
         return [r.as_tuple() for r in getattr(request, 'children', [])]
示例#7
0
 def current_task_children(self, request=None):
     request = request or getattr(current_task(), 'request', None)
     if request:
         return [r.as_tuple() for r in getattr(request, 'children', [])]
示例#8
0
文件: base.py 项目: liushigit/celery
 def current_task_children(self):
     current = current_task()
     if current:
         return [r.serializable() for r in current.request.children]