title: At what point does celery store result?
body: <p>I am using celery + redis for tasks in Django web app. The problem is that I don't know at what point does celery store it's task result as JSON object into DB. Afterwards an issue is raised because it cannot store np array as JSON.</p>
  
  <pre><code>import numpy as np
  from scipy.sparse import dok_matrix
  
  
  @shared_task(name="run_shortest_path_on_warehouse")
  def run_shortest_path_on_warehouse(adjacency_matrix):
      sparse_matrix = dok_matrix(adjacency_matrix)
      dist_matrix = dijkstra_algorithm(sparse_matrix).tolist()
      return {'optimal_distance_matrix': dist_matrix}
  </code></pre>
  
  <p>Celery can't store the result, because of this exception:</p>
  
  <pre><code>{"exc_type": "EncodeError", "exc_message": ["TypeError(\"Object of type 'ndarray' is not JSON serializable\",)"], "exc_module":    "kombu.exceptions"}
  </code></pre>
  
  <p>I know that numpy array isn't simply JSON serializable. That's why I used <code>.tolist</code> method in defining the <code>dist_matrix</code> variable. </p>
  
  <p>The question is, at what point does celery store it's variable and how can I store info from numpy array as task result?</p>