2 回答
TA贡献1936条经验 获得超6个赞
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import threadpool import time
def Main_Def(par1, par2, par3): print "par1 = %s, par2 = %s, par3 = %s" % (par1, par2, par3)
if __name__ == '__main__': # 方法1 list_var1 = ['1', '2', '3'] list_var2 = ['4', '5', '6'] par_list = [(list_var1, None), (list_var2, None)] # 方法2 # dict_var1 = {'par1': '1', 'par2': '2', 'par3': '3'} # dict_var2 = {'par1': '4', 'par2': '5', 'par3': '6'} # par_list = [(None, dict_var1), (None, dict_var2)]
pool = threadpool.ThreadPool(2) requests = threadpool.makeRequests(Main_Def, par_list) [pool.putRequest(req) for req in requests] time.sleep(1) pool.wait() |
添加回答
举报