Tuesday, 27 September 2016

How to can apply multithreading for a for loop in python

I am new to python , One command in my code is taking long time to execute and I need to execute it multiple time according to a list.I want to implement mutithreading here .In below code getcmdresult is taking a long time to return a value .Can someone please suggest how I can use mutithreading to reduce the time. Thanks in advance.


def getcmdresult(cmd, query):
#process to return a json array
return json_array
def get_details(list, query):
resultlist=[]
for item in list:
cmd = "cmd "+item["name"]
value=getcmdresult(cmd, query)
resultlist.append(value)
return resultlist

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...