Spaces:
Running
Running
evanzyfan commited on
Commit ·
a434439
1
Parent(s): f0a58e4
update app.py
Browse files
app.py
CHANGED
|
@@ -156,6 +156,11 @@ def get_reference_portraits(story_id: str) -> List[Tuple[str, str]]:
|
|
| 156 |
_save_lock = threading.Lock()
|
| 157 |
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
# ============================================================================
|
| 160 |
# Group Management
|
| 161 |
# ============================================================================
|
|
@@ -241,7 +246,7 @@ def create_group_config(group_id: str) -> Dict[str, Any]:
|
|
| 241 |
"method_display_map": method_display_map,
|
| 242 |
}
|
| 243 |
|
| 244 |
-
with
|
| 245 |
with open(group_dir / "mapping.json", "w", encoding="utf-8") as f:
|
| 246 |
json.dump(config, f, indent=2, ensure_ascii=False)
|
| 247 |
|
|
@@ -272,7 +277,7 @@ def save_ranking_result(
|
|
| 272 |
}
|
| 273 |
|
| 274 |
filepath = story_dir / filename
|
| 275 |
-
with
|
| 276 |
story_dir.mkdir(parents=True, exist_ok=True)
|
| 277 |
with open(filepath, "w", encoding="utf-8") as f:
|
| 278 |
json.dump(result_data, f, indent=4, ensure_ascii=False)
|
|
|
|
| 156 |
_save_lock = threading.Lock()
|
| 157 |
|
| 158 |
|
| 159 |
+
def _get_lock():
|
| 160 |
+
"""Return the scheduler lock if available, otherwise use the local lock."""
|
| 161 |
+
return scheduler.lock if scheduler is not None else _save_lock
|
| 162 |
+
|
| 163 |
+
|
| 164 |
# ============================================================================
|
| 165 |
# Group Management
|
| 166 |
# ============================================================================
|
|
|
|
| 246 |
"method_display_map": method_display_map,
|
| 247 |
}
|
| 248 |
|
| 249 |
+
with _get_lock():
|
| 250 |
with open(group_dir / "mapping.json", "w", encoding="utf-8") as f:
|
| 251 |
json.dump(config, f, indent=2, ensure_ascii=False)
|
| 252 |
|
|
|
|
| 277 |
}
|
| 278 |
|
| 279 |
filepath = story_dir / filename
|
| 280 |
+
with _get_lock():
|
| 281 |
story_dir.mkdir(parents=True, exist_ok=True)
|
| 282 |
with open(filepath, "w", encoding="utf-8") as f:
|
| 283 |
json.dump(result_data, f, indent=4, ensure_ascii=False)
|