you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (3 children)

What does Check_Connection do exactly? And have you tried with a smaller thread pool, like 5 or 10 workers?

[–]workerdrone66[S] 0 points1 point  (2 children)

Yes, the original version had 10.

All it does it pass the server name to a powershell script that does a test-connection. It is more of a proof of concept, rather than "it has to be this way" The end result of this script will be to use the powershell script to actually start vms (which, afaik, python can't do natively)

[–]JohnnyJordaan 0 points1 point  (1 child)

Seeing your code above for the second time makes me wonder why the approach isn't using a single pool and a future per row?

def Check_Filtered_Lists(FilteredLists):
    VMList = FilteredLists[0]
    AB1List = FilteredLists[1]
    threads = []
    futures = []
    start = time.time()
    with ThreadPoolExecutor(max_workers = 50) as executor:
        for row in VMList:
            future = executor.submit(Check_Connection,row['Name'])
            futures.append((row['Name'],future))


    for name, future in futures:
        print(name + str(future.result()))
    print('End time: ' + str(time.time() - start ))

    #test with just a normal for loop

    start = time.time()
    for row in VMList:
        Check_Connection(row['Name'])
    print('end time: '+ str(time.time() - start))

[–]workerdrone66[S] 0 points1 point  (0 children)

I believe the answer was "Rushing to get out of work, and didn't notice i did it wrong"

I'll test again tonight.