Many threads to write log file at same time in Python
问题 I am writing a script to retrieve WMI info from many computers at the same time then write this info in a text file: f = open("results.txt", 'w+') ## to clean the results file before the start def filesize(asset): f = open("results.txt", 'a+') c = wmi.WMI(asset) wql = 'SELECT FileSize,Name FROM CIM_DataFile where (Drive="D:" OR Drive="E:") and Caption like "%file%"' for item in c.query(wql): print >> f, item.Name.split("\\")[2].strip().upper(), str(item.FileSize) class myThread (threading