Answers for "SDL2_Thread get return"

3

python thread with return values?

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)
Posted by: Guest on November-03-2020

Python Answers by Framework

Browse Popular Code Answers by Language