Spaces:
Running
on
Zero
Running
on
Zero
get_tasks modified
Browse files
app.py
CHANGED
@@ -244,13 +244,20 @@ def task_status(task_id):
|
|
244 |
return jsonify({'error': str(e)}), 500
|
245 |
|
246 |
def get_active_task_order(task_id):
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
# get_task_orderイベントハンドラー
|
256 |
@app.route('/get_task_order/<task_id>', methods=['GET'])
|
|
|
244 |
return jsonify({'error': str(e)}), 500
|
245 |
|
246 |
def get_active_task_order(task_id):
|
247 |
+
try:
|
248 |
+
if task_id not in active_tasks.keys():
|
249 |
+
return 0
|
250 |
+
if active_tasks[task_id].is_processing:
|
251 |
+
return 0
|
252 |
+
processing_task_ids = [tid for tid, task in active_tasks.items() if task.is_processing]
|
253 |
+
non_processing_task_ids = [tid for tid, task in active_tasks.items() if not task.is_processing]
|
254 |
+
if len(processing_task_ids) == 0:
|
255 |
+
task_order = 0
|
256 |
+
else:
|
257 |
+
task_order = non_processing_task_ids.index(task_id) + 1
|
258 |
+
return task_order
|
259 |
+
except Exception as e:
|
260 |
+
print(f"Error getting task order: {str(e)}")
|
261 |
|
262 |
# get_task_orderイベントハンドラー
|
263 |
@app.route('/get_task_order/<task_id>', methods=['GET'])
|