'_csv.Error: iterable expected, not NoneType

Script works, it scans info correctly, builds a list of info, and writes to a csv. However, it sometimes throws a _csv.Error: iterable expected, not NoneType error.

List = []

with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
    futures = []
    for i in ip:
        futures.append(executor.submit(machine_scan, 'root', pwd, i))
    for future in as_completed(futures):
        List.append(future.result())
    #print(List)
    
outFile = "Output/" + post_file
cols = ['IP','Asset','Location','Hostname','Workername','Type', 'Board', 'Workmode', 'Firmware']
with open(outFile, 'w',newline = "") as csvwfile:
    writer = csv.writer(csvwfile)
    writer.writerow(cols)
    writer.writerows(List)

Mostly confused how it writes to the csv file while also throwing an error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source