code: def catch_result(task_func):
      
  
      @functools.wraps(task_func, assigned=available_attrs(task_func))
      def dec(*args, **kwargs):
          # inicialize
          orig_stdout = sys.stdout
          sys.stdout = content = StringIO()
          task_response = task_func(*args, **kwargs)
          # catch
          sys.stdout = orig_stdout
          content.seek(0)
          # propagate to the response
          task_response['stdout'] = content.read()
          return task_response
      return dec
docs: Catch printed result from Celery Task and return it in task response