ldhldh commited on
Commit
4d210d2
·
1 Parent(s): ee39537

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -19
app.py CHANGED
@@ -35,28 +35,31 @@ routes.get_types = get_types
35
  q = queue.Queue()
36
 
37
  def chat():
38
- global q
39
- if not q.empty():
40
- arr = q.get()
41
- start = time.time()
42
- result = gradio_client.predict(
43
- arr[0],
44
- # str representing input in 'User input' Textbox component
45
- arr[1],
46
- arr[2],
47
- fn_index=0
48
- )
49
- result = str(result)
 
 
 
 
 
50
 
51
- end = time.time()
52
-
53
-
54
- sec = (end - start)
55
- result_list = str(datetime.timedelta(seconds=sec)).split(".")
56
- print("응답 시간 : " + result_list[0] +"\nx:"+ arr[0] +"\nid:"+ arr[1] +"\ncdata:" + arr[2] +"\nresult:"+ result + "\ncollback_url : " + arr[3])
57
- return result
58
 
59
  th_a = Thread(target = chat)
 
60
  th_a.start()
61
 
62
  # App code
 
35
  q = queue.Queue()
36
 
37
  def chat():
38
+ while True:
39
+ time.sleep(1)
40
+ global q
41
+ if not q.empty():
42
+ arr = q.get()
43
+ start = time.time()
44
+ result = gradio_client.predict(
45
+ arr[0],
46
+ # str representing input in 'User input' Textbox component
47
+ arr[1],
48
+ arr[2],
49
+ fn_index=0
50
+ )
51
+ result = str(result)
52
+
53
+ end = time.time()
54
+
55
 
56
+ sec = (end - start)
57
+ result_list = str(datetime.timedelta(seconds=sec)).split(".")
58
+ print("응답 시간 : " + result_list[0] +"\nx:"+ arr[0] +"\nid:"+ arr[1] +"\ncdata:" + arr[2] +"\nresult:"+ result + "\ncollback_url : " + arr[3])
59
+ return result
 
 
 
60
 
61
  th_a = Thread(target = chat)
62
+ th_a.daemon = True
63
  th_a.start()
64
 
65
  # App code