本文整理汇总了Python中threading.Thread.result_queue方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.result_queue方法的具体用法?Python Thread.result_queue怎么用?Python Thread.result_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.result_queue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_func
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import result_queue [as 别名]
def async_func(*args, **kwargs):
""" Run a function asynchronously
:param args: all arguments will be passed to the target function
:param kwargs: pass a Queue.Queue() object with the optional 'queue' keyword if you would like to retrieve
the results after the thread has run. All other keyword arguments will be passed to the target function.
:return: the created Thread object that the function is running in.
"""
t = Thread(target=func, args=args, kwargs=kwargs)
queue = kwargs.get("queue", None)
if queue is not None:
t.result_queue = queue
t.start()
return t