rohan13 commited on
Commit
6cb4a02
·
1 Parent(s): aa2ddf1

handling negative use cases

Browse files
Files changed (1) hide show
  1. app.py +3 -2
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
- executor = concurrent.futures.ThreadPoolExecutor(max_workers=4)
 
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 len(executor.threads) >= executor.max_workers:
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