Spaces:
Runtime error
Runtime error
handling negative use cases
Browse files
app.py
CHANGED
@@ -9,7 +9,8 @@ app.config['SECRET_KEY'] = 'secret!'
|
|
9 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
10 |
cors = CORS(app)
|
11 |
|
12 |
-
|
|
|
13 |
|
14 |
@app.route('/')
|
15 |
def index():
|
@@ -21,7 +22,7 @@ def handle_message(data):
|
|
21 |
question = data['question']
|
22 |
print("question: " + question)
|
23 |
|
24 |
-
if
|
25 |
emit('response', {'response': 'Server is busy, please try again later'})
|
26 |
return
|
27 |
|
|
|
9 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
10 |
cors = CORS(app)
|
11 |
|
12 |
+
max_workers=4
|
13 |
+
executor = concurrent.futures.ThreadPoolExecutor(max_workers)
|
14 |
|
15 |
@app.route('/')
|
16 |
def index():
|
|
|
22 |
question = data['question']
|
23 |
print("question: " + question)
|
24 |
|
25 |
+
if executor._work_queue.qsize() >= max_workers:
|
26 |
emit('response', {'response': 'Server is busy, please try again later'})
|
27 |
return
|
28 |
|