In the following code I am calling getSUEPEvent() funtion 4 time for single loop. I restart loop again for next 4. Still execution keeps on adding to loop. If loop is global than can any one suggest another strategy to can funtion n number of time by grouping or any else means.
def SEUPCustomers(featurecode,threshholdTime):
# headers = buildHeaders()
with open("ActiveCustomers.csv","r") as f:
SEUPCustomersList = []
csvReader = csv.reader(f)
tasks = []
for row in csvReader:
tasks.append(asyncio.ensure_future(getSEUPEvents(featurecode,row,threshholdTime,SEUPCustomersList)))
for task in range(0,len(tasks),4):
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks[task:task+4]))
loop.close()