Explorar o código

fix timeout error

ming %!s(int64=3) %!d(string=hai) anos
pai
achega
dd54dcf94f
Modificáronse 1 ficheiros con 10 adicións e 2 borrados
  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')