I have a thread with for loop inside that I want to return the value from each loop. But when I put return inside the loop,it break the loop permanently so I can't get other value.
Here is my function:
def track_duration_count(track_length):
time.sleep(13.2)
for i in range(0,track_length):
timer = str(datetime.timedelta(seconds=i))
#sys.stdout.write(str(i)+' ')
#sys.stdout.flush()
return timer
print (timer)
time.sleep(1)
global stop_thread
if stop_thread:
break
print ("BREAKFREE")
I then call the function with:
_thread.start_new_thread(track_duration_count,(track_length,))
I want to use timer from this func for another thread.
threading.Threadand store the results as an attribute 2) Usemultiprocessing.dummy.Pools map function 3) Add the results to a list, since lists will be passed as reference.