Browse Source

fix timeout error

ming 3 năm trước cách đây
mục cha
commit
dd54dcf94f
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      api/main.py

+ 10 - 2
api/main.py

@@ -134,8 +134,16 @@ def get_url_type(url):
 def gen_video(name_hash,name,text_content, image_urls,avatar,client_id):
     c = rpyc.connect("localhost", 8878)
     remote_svc = c.root
-    my_answer = remote_svc.call_video(name_hash,name,text_content, image_urls,avatar,client_id) # method call
-    
+    try:
+        my_answer = remote_svc.call_video(name_hash,name,text_content, image_urls,avatar,client_id) # method call
+    except:
+        print('maybe time out error')
+    while True:
+        print('waiting...')
+        if os.path.exists(tmp_video_dir+name_hash+'.mp4'):
+            break
+        time.sleep(5)
+        print('waiting...')
     shutil.copy(tmp_video_dir+name_hash+'.mp4',video_dest+name_hash+'.mp4')
     os.remove(tmp_video_dir+name_hash+'.mp4')