当我调用“ pool.apply(engine,args =(reminder_stream,streams_total,12,
reminder_duration,templates,templates_classes)“我遇到运行时错误”试图在启动新进程之前 当前进程已完成其引导阶段。
这可能意味着您没有使用fork来启动子进程,并且忘记了在主模块中使用适当的习惯用法:if name ==' main >':Frozen_support()...如果不打算冻结程序以生成可执行文件,则可以省略“ freeze_support()”行。”
```python
def engine(stream_reminder, total_streams, stream_id, duration_reminder, templates, templates_classes):
stream = get_stream_data(stream_id)
if stream != "":
optimized_stream, timestamps = optimize_stream(stream)
if len(stream_reminder) != 0:
optimized_stream = np.concatenate((stream_reminder, optimized_stream), axis=None)
timestamps = np.concatenate((duration_reminder, timestamps), axis=None)
stream_cuts, stream_reminder, stream_durations, duration_reminder = cut_stream(optimized_stream, 13, 125,
timestamps)
if len(stream_cuts) > 0:
submit_stream_cuts(stream_id, stream_cuts, stream_durations)
total_streams = total_streams + stream_cuts
print(len(total_streams))
for i in range(len(stream_cuts)):
stream_cut_result = classifiy_stroke(templates,stream_cuts[i], templates_classes)
submit_stroke_result(stream_cut_result,stream_cuts[i])
print(len(total_streams))
threading.Timer(2.0, engine, [stream_reminder, total_streams, stream_id, duration_reminder, templates, templates_classes]).start()
```
reminder_stream = []
streams_total = []
reminder_duration = []
templates, templates_classes = get_stroke_templates()
for i in range(len(templates)):
templates[i] = filter_stream(templates[i], False, False)
import multiprocessing as mp
pool = mp.Pool(mp.cpu_count())
results = [pool.apply(engine, args=(reminder_stream, streams_total ,12, reminder_duration,templates, templates_classes))]
pool.close()