Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -125,8 +125,17 @@ def demucs_separator(audio, checkpoint_name):
|
|
125 |
|
126 |
# 任务队列和状态存储
|
127 |
tasks = {}
|
|
|
|
|
128 |
|
129 |
def process_audio_separation(task_id, mp3_url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
try:
|
131 |
# 下载MP3文件到本地
|
132 |
response = requests.get(mp3_url)
|
@@ -154,6 +163,9 @@ def process_audio_separation(task_id, mp3_url):
|
|
154 |
"status": "error",
|
155 |
"message": str(e)
|
156 |
}
|
|
|
|
|
|
|
157 |
|
158 |
app = Flask(__name__)
|
159 |
|
|
|
125 |
|
126 |
# 任务队列和状态存储
|
127 |
tasks = {}
|
128 |
+
running_threads = 0
|
129 |
+
condition = threading.Condition()
|
130 |
|
131 |
def process_audio_separation(task_id, mp3_url):
|
132 |
+
global running_threads
|
133 |
+
with condition:
|
134 |
+
while running_threads >= 1:
|
135 |
+
tasks[task_id] = {"status": "queue"}
|
136 |
+
condition.wait()
|
137 |
+
running_threads += 1
|
138 |
+
tasks[task_id] = {"status": "processing"}
|
139 |
try:
|
140 |
# 下载MP3文件到本地
|
141 |
response = requests.get(mp3_url)
|
|
|
163 |
"status": "error",
|
164 |
"message": str(e)
|
165 |
}
|
166 |
+
with condition:
|
167 |
+
running_threads -= 1
|
168 |
+
condition.notify_all()
|
169 |
|
170 |
app = Flask(__name__)
|
171 |
|