matplotlib 是进程安全的,不是线程安全的。
应该使用python的multiprocessing.Pool,而不是ThreadPool。
import multiprocessing
pool=multiprocessing.Pool(processes=10) # processes可以调用的core数目
for i in range(0,357):
pool.map(fitting, filenames[i*10:i*10+10])
pool.close() # 一定要在for循环的外面
pool.join() #要在for循环的外面
https://stackoverflow.com/questions/55179881/multithreading-matplotlib-graph-in-a-kivy-app
网友评论