What is the best way to call same function in separate threads and have a separate list with returned values for each instance, without duplicating function?
Example:
import threading
def function(a):
    returned_values = []
    ct = threading.currentThread() 
    while getattr(ct, "do_run", True):
        ret = do_something(a)
        returned_values.append(ret)
t1 = threading.Thread(target=function, args=("AAA",))
t2 = threading.Thread(target=function, args=("BBB",))
t3 = threading.Thread(target=function, args=("CCC",))
t1.start()
t2.start()
t3.start()
import time;time.sleep(10)
t1.do_run = t2.do_run = t3.do_run = False
EDIT: Forgot to mention that I use Python 2.7
 
     
     
    