From be1a68efc1ab7c6ec85fcf282c82685f83cf438a Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke.madsen@geant.org> Date: Tue, 2 Mar 2021 16:14:10 +0100 Subject: [PATCH] Return immediately on request to /update. The processing takes longer than the timeout, do it in the background. --- brian_dashboard_manager/routes/update.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/brian_dashboard_manager/routes/update.py b/brian_dashboard_manager/routes/update.py index eb7c2d5..681c867 100644 --- a/brian_dashboard_manager/routes/update.py +++ b/brian_dashboard_manager/routes/update.py @@ -1,3 +1,4 @@ +from concurrent.futures import ThreadPoolExecutor from flask import Blueprint, current_app from brian_dashboard_manager.routes import common from brian_dashboard_manager.grafana.provision import provision @@ -13,5 +14,6 @@ def after_request(resp): @routes.route('/', methods=['GET']) def update(): - success = provision(current_app.config[CONFIG_KEY]) - return {'data': success} + executor = ThreadPoolExecutor(max_workers=1) + executor.submit(provision, current_app.config[CONFIG_KEY]) + return {'data': {'message': 'Provisioning dashboards!'}} -- GitLab