Spaces:
Runtime error
Runtime error
handling negative use cases
Browse files
app.py
CHANGED
@@ -21,11 +21,17 @@ def handle_message(data):
|
|
21 |
question = data['question']
|
22 |
print("question: " + question)
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
if __name__ == '__main__':
|
31 |
socketio.run(app, host="0.0.0.0", port=7860)
|
|
|
21 |
question = data['question']
|
22 |
print("question: " + question)
|
23 |
|
24 |
+
if len(executor.threads) >= executor.max_workers:
|
25 |
+
emit('response', {'response': 'Server is busy, please try again later'})
|
26 |
+
return
|
27 |
+
|
28 |
+
try:
|
29 |
+
future = executor.submit(run, question)
|
30 |
+
response = future.result()
|
31 |
+
emit('response', {'response': response})
|
32 |
+
except Exception as e:
|
33 |
+
print(f"Error processing request: {str(e)}")
|
34 |
+
emit('response', {'response': 'Server is busy. Please try again later.'})
|
35 |
|
36 |
if __name__ == '__main__':
|
37 |
socketio.run(app, host="0.0.0.0", port=7860)
|