如何在计算机上运行最大数量的线程? 我想在我的python代码中运行最大线程数。 我在Windows计算机上运行代码。
我考虑了以下解决方案:
x = 0
while 1:
try:
t = Thread(target=learn,args=(line,)) #writer,))
thread_list.append(t)
t.start()
break
except Exception as exp:
time.sleep(1)
if x == 0:
print "Waiting for free thread",x = 1
else:
print ".",
代码工作正常,但几分钟后出现以下错误:
mutex.acquire() #error
with open("output.csv","ab") as dataset_file:
writer = csv.writer(dataset_file)
writer.writerow(dataset)
mutex.release()
mutex.acquire()
AttributeError: 'NoneType' object has no attribute 'acquire'
有人可以解决我的错误,也可以通过其他方法来打开最大数量的线程吗? 谢谢。