运行结果
Python多进程调用示例
import multiprocessing
import time
import os
import sys
# 注册多个函数用于不同进程分别调用
def testcase0():
time.sleep(1)
return "case0_"+get_time()
def testcase1(timestamp):
return "case1_"+timestamp
def testcase2(timestamp):
return "case2_"+timestamp
def testcase3(timestamp):
print(timestamp)
return
# 初始化各进程函数
generate_func = testcase0
gather_func = testcase1
process_func = testcase2
show_func = testcase3
#generate_func = None
#gather_func = None
#process_func = None
#show_func = None
# 暂时无用
def proc_init(_generate, _gather, _process, _show):
global generate_func
global gather_func