rogerxavier commited on
Commit
1ad0d49
1 Parent(s): 06b483d

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +12 -6
api.py CHANGED
@@ -92,19 +92,25 @@ async def execute_py_file(file_name: str,background_tasks: BackgroundTasks):
92
 
93
 
94
 
95
- #收到图片后为了后台任务的顺序,单独设定一个函数依次将1去水印,2裁剪,3合并按照顺序加入后台任务队列
 
 
 
 
 
 
 
 
96
  @app.get("/execute_all_task")
97
- async def execute_all_task(background_tasks: BackgroundTasks):
98
- background_tasks.add_task(file_executer,"1removeMask")
99
- background_tasks.add_task(file_executer,"2magiDialogCut")
100
- background_tasks.add_task(file_executer,"3mergeDialogToVideo")
101
  return {"message": "Tasks added to the queue"}
102
 
103
 
104
 
105
 
106
 
107
-
108
  ##########异步样例
109
  def someTask():
110
  time.sleep(20)
 
92
 
93
 
94
 
95
+ # #收到图片后为了后台任务的顺序,单独设定一个函数依次将1去水印,2裁剪,3合并按照顺序加入后台任务队列
96
+ # @app.get("/execute_all_task")
97
+ # async def execute_all_task(background_tasks: BackgroundTasks):
98
+ # background_tasks.add_task(file_executer,"1removeMask")
99
+ # background_tasks.add_task(file_executer,"2magiDialogCut")
100
+ # background_tasks.add_task(file_executer,"3mergeDialogToVideo")
101
+ # return {"message": "Tasks added to the queue"}
102
+
103
+ #收到图片后为了后台任务的顺序,单独设定一个函数依次将自定义执行顺序加入队列
104
  @app.get("/execute_all_task")
105
+ async def execute_all_task(file_list: list = ["1removeMask", "2magiDialogCut", "3mergeDialogToVideo"], background_tasks: BackgroundTasks):
106
+ for file_name in file_list:
107
+ background_tasks.add_task(file_executer, file_name)
 
108
  return {"message": "Tasks added to the queue"}
109
 
110
 
111
 
112
 
113
 
 
114
  ##########异步样例
115
  def someTask():
116
  time.sleep(20)