zhangjf commited on
Commit
8e3ee3f
1 Parent(s): 02840bb

support dynamic timeout

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -130,14 +130,14 @@ def askingChatGPT(qs, qas, min_interval_seconds=3, max_interval_seconds=15, max_
130
  a = future.result(timeout=timeout) # 等待函数调用任务完成,超时时间为30秒
131
  return a
132
  except concurrent.futures.TimeoutError:
133
- print('ask call timed out after', timeout, 'seconds, retrying...')
134
  executor.shutdown(wait=False)
135
  return ask_(q, timeout*2) # 当超时时,重新调用函数
136
 
137
  retry_times = 0
138
  a = None
139
  while a is None and retry_times<max_retry_times:
140
- a = ask_(q, timeout=np.mean(sorted(history_elapsed_time)[:8]))
141
  retry_times += 1
142
 
143
  qas.append({"q":q, "a":a})
 
130
  a = future.result(timeout=timeout) # 等待函数调用任务完成,超时时间为30秒
131
  return a
132
  except concurrent.futures.TimeoutError:
133
+ print(f"ask call timed out after {timeout:.2f} seconds, retrying...")
134
  executor.shutdown(wait=False)
135
  return ask_(q, timeout*2) # 当超时时,重新调用函数
136
 
137
  retry_times = 0
138
  a = None
139
  while a is None and retry_times<max_retry_times:
140
+ a = ask_(q, timeout=np.mean(sorted(history_elapsed_time)[:8])*2)
141
  retry_times += 1
142
 
143
  qas.append({"q":q, "a":a})