Wrong app context for CSV task
We need to run the CSV importer task in the correct context.
diff --git a/timesketch/lib/tasks.py b/timesketch/lib/tasks.py
index 83d0b164..b91cef84 100644
--- a/timesketch/lib/tasks.py
+++ b/timesketch/lib/tasks.py
@@ -121,9 +121,10 @@ def run_csv(source_file_path, timeline_name, index_name, username=None):
     total_events = es.import_event(flush_interval, index_name, event_type)
 
     # We are done so let's remove the processing status flag
-    search_index = SearchIndex.query.filter_by(index_name=index_name).first()
-    search_index.status.remove(search_index.status[0])
-    db_session.add(search_index)
-    db_session.commit()
+    with celery.app.app_context():
+        search_index = SearchIndex.query.filter_by(index_name=index_name).first()
+        search_index.status.remove(search_index.status[0])
+        db_session.add(search_index)
+        db_session.commit()
 
     return {u'Events processed': total_events}
['timesketch/lib/tasks.py']