|
@@ -3,12 +3,14 @@
|
|
|
"""
|
|
|
|
|
|
import datetime
|
|
|
+import multiprocessing
|
|
|
|
|
|
from applications import log
|
|
|
from coldStartTasks.ai_pipeline import ExtractVideoBestFrame
|
|
|
|
|
|
+PROCESS_EXIT_TIMEOUT = 10 * 60
|
|
|
|
|
|
-def main():
|
|
|
+def start_task():
|
|
|
task = ExtractVideoBestFrame()
|
|
|
|
|
|
# 查询有多少任务正在处理中
|
|
@@ -34,5 +36,19 @@ def main():
|
|
|
task.get_cover_with_best_frame()
|
|
|
|
|
|
|
|
|
+def main():
|
|
|
+ # create sub process
|
|
|
+ process = multiprocessing.Process(target=start_task)
|
|
|
+ process.start()
|
|
|
+
|
|
|
+ # wait for sub process to finish
|
|
|
+ process.join(PROCESS_EXIT_TIMEOUT)
|
|
|
+
|
|
|
+ if process.is_alive():
|
|
|
+ print(f"Process {process.pid} did not finish within {PROCESS_EXIT_TIMEOUT} seconds. Terminating...")
|
|
|
+ process.terminate()
|
|
|
+ process.join()
|
|
|
+
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
main()
|