将多个参数传递给python threading.Thread
Python版本:Python 2.7(我没有升级的权限) 我有以下代码,对我来说很有效:将多个参数传递给python threading.Thread,python,multithreading,python-2.x,python-multithreading,Python,Multithreading,Python 2.x,Python Multithreading,Python版本:Python 2.7(我没有升级的权限) 我有以下代码,对我来说很有效: cFiles = 10 list_of_columns = List_Of_files p = Pool(processes=cFiles) data = p.map(analyzefiles, [i for i in list_of_columns]) p.close() 这使用了多处理模块 当我尝试将相同的逻辑应用于线程模块时,我最终不得不运行以下for循环,这不是我想要的: for i in pr
cFiles = 10
list_of_columns = List_Of_files
p = Pool(processes=cFiles)
data = p.map(analyzefiles, [i for i in list_of_columns])
p.close()
这使用了多处理
模块
当我尝试将相同的逻辑应用于线程
模块时,我最终不得不运行以下for循环
,这不是我想要的:
for i in prodentries:
newi = "pOfList:::" + i
t1 = threading.Thread(target=analyzelogs, args=(newi,) )
t1.start()
t1.join()
我的问题是,如何将上面的for循环
转换为更高效的代码?我真的更喜欢使用线程
模块。大致如下:
t1 = threading.ThreadPool(target=analyzefiles, [ "pOfList:::" + i for i in prodentries] )
t1.start()
t1.join()
你可以试试。那需要蟒蛇3