1import threading
2import queue
3
4my_queue = queue.Queue()
5
6def storeInQueue(f):
7 def wrapper(*args):
8 my_queue.put(f(*args))
9 return wrapper
10
11
12@storeInQueue
13def get_name(full_name):
14 return full_name, full_name
15
16
17
18t = threading.Thread(target=get_name, args = ("foo", ))
19t.start()
20
21my_data = my_queue.get()
22print(my_data)
23
1import concurrent.futures
2
3def foo(bar):
4 print('hello {}'.format(bar))
5 return 'foo'
6
7with concurrent.futures.ThreadPoolExecutor() as executor:
8 future = executor.submit(foo, 'world!')
9 return_value = future.result()
10 print(return_value)
11