📜  带有返回值的python线程? - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:22.049000             🧑  作者: Mango

代码示例1
import threading
import queue

my_queue = queue.Queue()

def storeInQueue(f):
  def wrapper(*args):
    my_queue.put(f(*args))
  return wrapper


@storeInQueue
def get_name(full_name):
   return full_name, full_name



t = threading.Thread(target=get_name, args = ("foo", ))
t.start()

my_data = my_queue.get()
print(my_data)