hadadrjt commited on
Commit
b8dd135
·
1 Parent(s): 2ca3c02

ai: Replace some Python deprecated function.

Browse files

/home/user/app/jarvis.py:285: DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
done, pending = await asyncio.wait({task, sess.stop_event.wait()}, return_when=asyncio.FIRST_COMPLETED)

Files changed (1) hide show
  1. jarvis.py +4 -2
jarvis.py CHANGED
@@ -282,13 +282,15 @@ async def respond_async(multi, history, model_display, sess, custom_prompt):
282
  history.append([inp, RESPONSES["RESPONSE_8"]])
283
  yield history, gr.update(interactive=False, submit_btn=False, stop_btn=True), sess
284
  task = asyncio.create_task(chat_with_model_async(history, inp, model_display, sess, custom_prompt))
285
- done, pending = await asyncio.wait({task, sess.stop_event.wait()}, return_when=asyncio.FIRST_COMPLETED)
286
- if sess.stop_event.is_set():
 
287
  task.cancel()
288
  history[-1][1] = RESPONSES["RESPONSE_1"]
289
  yield history, gr.update(value="", interactive=True, submit_btn=True, stop_btn=False), sess
290
  sess.stop_event.clear()
291
  return
 
292
  ai = task.result()
293
  history[-1][1] = ""
294
  buffer = []
 
282
  history.append([inp, RESPONSES["RESPONSE_8"]])
283
  yield history, gr.update(interactive=False, submit_btn=False, stop_btn=True), sess
284
  task = asyncio.create_task(chat_with_model_async(history, inp, model_display, sess, custom_prompt))
285
+ stop_task = asyncio.create_task(sess.stop_event.wait())
286
+ done, pending = await asyncio.wait({task, stop_task}, return_when=asyncio.FIRST_COMPLETED)
287
+ if stop_task in done:
288
  task.cancel()
289
  history[-1][1] = RESPONSES["RESPONSE_1"]
290
  yield history, gr.update(value="", interactive=True, submit_btn=True, stop_btn=False), sess
291
  sess.stop_event.clear()
292
  return
293
+ stop_task.cancel()
294
  ai = task.result()
295
  history[-1][1] = ""
296
  buffer = []