liuyiyang01 commited on
Commit
0a3469e
·
1 Parent(s): acf15aa

fix unload bug

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -528,8 +528,8 @@ def update_log_display():
528
  ###############################################################################
529
 
530
 
531
- def cleanup_session(request: gr.Request):
532
- session_id = request.session_hash
533
  task_id = SESSION_TASKS.pop(session_id, None)
534
 
535
  if task_id:
@@ -544,7 +544,9 @@ def cleanup_session(request: gr.Request):
544
  print(f"终止任务失败 {task_id}: {res.get('status', 'unknown issue')}")
545
  except Exception as e:
546
  print(f"终止任务失败 {task_id}: {e}")
547
-
 
 
548
 
549
 
550
  ###############################################################################
@@ -639,9 +641,7 @@ def start_session(req: gr.Request):
639
  os.makedirs(user_dir, exist_ok=True)
640
 
641
 
642
- def end_session(req: gr.Request):
643
- user_dir = os.path.join(TMP_ROOT, str(req.session_hash))
644
- shutil.rmtree(user_dir)
645
 
646
 
647
  # 创建Gradio界面
@@ -794,7 +794,7 @@ with gr.Blocks(title="InternManip Model Inference Demo", css=custom_css) as demo
794
 
795
  demo.queue(default_concurrency_limit=8)
796
 
797
- demo.unload(fn=cleanup_session).then(end_session)
798
 
799
 
800
  # 启动应用
 
528
  ###############################################################################
529
 
530
 
531
+ def cleanup_session(req: gr.Request):
532
+ session_id = req.session_hash
533
  task_id = SESSION_TASKS.pop(session_id, None)
534
 
535
  if task_id:
 
544
  print(f"终止任务失败 {task_id}: {res.get('status', 'unknown issue')}")
545
  except Exception as e:
546
  print(f"终止任务失败 {task_id}: {e}")
547
+
548
+ user_dir = os.path.join(TMP_ROOT, str(req.session_hash))
549
+ shutil.rmtree(user_dir)
550
 
551
 
552
  ###############################################################################
 
641
  os.makedirs(user_dir, exist_ok=True)
642
 
643
 
644
+
 
 
645
 
646
 
647
  # 创建Gradio界面
 
794
 
795
  demo.queue(default_concurrency_limit=8)
796
 
797
+ demo.unload(fn=cleanup_session)
798
 
799
 
800
  # 启动应用