aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/utils/tasks.py13
-rw-r--r--boot.sh2
2 files changed, 14 insertions, 1 deletions
diff --git a/app/utils/tasks.py b/app/utils/tasks.py
index b0f5c27..8356876 100644
--- a/app/utils/tasks.py
+++ b/app/utils/tasks.py
@@ -5,13 +5,26 @@
"""
import random
+import multiprocessing
from flask import current_app
from app.models import Dataset, Task
+TASK_LOCK = multiprocessing.Lock()
+
def generate_user_task(user):
+ task = None
+ TASK_LOCK.acquire(timeout=10)
+ try:
+ task = realgenerate_user_task(user)
+ finally:
+ TASK_LOCK.release()
+ return task
+
+
+def realgenerate_user_task(user):
"""
Generate new task for a given user.
diff --git a/boot.sh b/boot.sh
index 93e64d2..c15b1c4 100644
--- a/boot.sh
+++ b/boot.sh
@@ -13,4 +13,4 @@ while true; do
sleep 5
done
-exec gunicorn -b :7831 --access-logfile - --error-logfile - annotate_change:app
+exec gunicorn -b :7831 --preload --access-logfile - --error-logfile - annotate_change:app