ming 3 лет назад
Родитель
Сommit
405ec4bf47
1 измененных файлов с 17 добавлено и 17 удалено
  1. 17 17
      api/main.py

+ 17 - 17
api/main.py

@@ -206,24 +206,24 @@ def gen_avatar(name_hash, imgurl):
         if len(works)==0:
             print('leave process loop')
             break
-     
-        statement = 'UPDATE avatar_service_status SET status = 1 WHERE id=1;'
-        db.query(statement)
-        name_hash = works[0]['name_hash']
-        imgurl = works[0]['imgurl']
-        print(works[0])
-        print(name_hash)
-        print(imgurl)
-        c = rpyc.connect("localhost", 8868)
-        c._config['sync_request_timeout'] = None
-        remote_svc = c.root
-        my_answer = remote_svc.call_avatar(name_hash,imgurl) # method call
-        shutil.copy(tmp_avatar_dir+name_hash+'.mp4',avatar_dest+name_hash+'.mp4')
-        os.remove(tmp_avatar_dir+name_hash+'.mp4')
+        try:
+            statement = 'UPDATE avatar_service_status SET status = 1 WHERE id=1;'
+            db.query(statement)
+            name_hash = works[0]['name_hash']
+            imgurl = works[0]['imgurl']
+            print(works[0])
+            print(name_hash)
+            print(imgurl)
+            c = rpyc.connect("localhost", 8868)
+            c._config['sync_request_timeout'] = None
+            remote_svc = c.root
+            my_answer = remote_svc.call_avatar(name_hash,imgurl) # method call
+            shutil.copy(tmp_avatar_dir+name_hash+'.mp4',avatar_dest+name_hash+'.mp4')
+            os.remove(tmp_avatar_dir+name_hash+'.mp4')
             
-      
-        print('gen error')
-        notify_group('無法辨識人臉')
+        except:
+            print('gen error')
+            notify_group('無法辨識人臉')
         db['avatar_queue'].delete(id=works[0]['id'])
         statement = 'UPDATE avatar_service_status SET status = 0 WHERE id=1;'  #only one row in this table, which id 1 one
         db.query(statement)