Preface -- I'm new to Python and programming in general. I am inheriting code and am attempting to modify existing code to make it more efficient.
Current issue is an existing "for server in serverlist" loop that appends the output to a list. It takes too long because it is processing the list one-by-one. It takes about 5seconds per machine lasting around 4minutes.
What do I need to do if I want to execute this single call on all 50 servers at once thereby getting back data for all 50 servers within a total of around 5 seconds? Or rather -- is there anything that can be done to speed this up in general to call on multiple machines at once instead of just one?
Current code example:
def dosomething(server):
stuff = []
try:
# function here
stuff = # function stuff here
except Exception:
pass
return stuff
def getdata(self):
serverlist = [servera, serverb, serverc]
data = []
for server in serverlist:
results = dosomething(server)
data.append(results)
return data