Fix gather extract: file-based tasks (multi-worker safe), correct status completed check

This commit is contained in:
Floppyrj45
2026-02-19 16:01:06 +01:00
parent a3b3a93ef2
commit c72ba38221
3 changed files with 36 additions and 2 deletions

View File

@@ -31,7 +31,41 @@ if not os.path.exists(TEMP_DIR):
os.makedirs(TEMP_DIR)
# Global task store
TASKS = {}
import threading
_task_lock = threading.Lock()
_TASK_FILE = '/tmp/seismic_tasks.json'
def _load_tasks():
try:
with open(_TASK_FILE) as f:
return json.load(f)
except:
return {}
def _save_tasks(tasks):
with open(_TASK_FILE, 'w') as f:
json.dump(tasks, f)
class TasksProxy:
def get(self, key, default=None):
return _load_tasks().get(key, default)
def __setitem__(self, key, value):
with _task_lock:
tasks = _load_tasks()
tasks[key] = value
_save_tasks(tasks)
def __getitem__(self, key):
return _load_tasks()[key]
def __contains__(self, key):
return key in _load_tasks()
def pop(self, key, *args):
with _task_lock:
tasks = _load_tasks()
result = tasks.pop(key, *args)
_save_tasks(tasks)
return result
TASKS = TasksProxy()
# ========== UTILITY FUNCTIONS ==========