From cda318eeeb308c33aee960ea5b16afda0df17987 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 17 Aug 2023 13:36:57 +1000 Subject: [PATCH] worker: Use threading to run new site in bg --- worker/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/worker/main.py b/worker/main.py index a792808..e739c80 100644 --- a/worker/main.py +++ b/worker/main.py @@ -3,6 +3,7 @@ from flask import Flask, request, jsonify import dotenv import os +import threading dotenv.load_dotenv() @@ -25,7 +26,9 @@ def new_site(): sites_file.close() # New site in background - new_site(domain,5000+count) + thread = threading.Thread(target=new_site, args=(domain, 5000 + count)) + thread.start() + # Return the domain and the number of sites return jsonify({'domain': domain, 'count': count})