📜  python returen 线程 - Python 代码示例

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

代码示例1
def foo(bar, baz):
  print 'hello {0}'.format(bar)
  return 'foo' + baz

from multiprocessing.pool import ThreadPool
pool = ThreadPool(processes=1)

async_result = pool.apply_async(foo, ('world', 'foo')) # tuple of args for foo

# do some other stuff in the main process

return_val = async_result.get()  # get the return value from your function.