我有线程,我想在它完成时更改一些标志。例如:
import threading
def on_done():
# do some printing or change some flags
def worker():
# do some calculations
t = threading.Thread(target=worker, on_close=on_done)
t.start()
但我找不到这样的方法。有什么办法吗?worker函数在separet文件中,因此它不知道标志。在
提前通知他
Tags:
一种选择是简单地包装worker函数:
然后,将目标设置为
^{pr2}$wrapped_worker
:有关更深入的示例,请参见this answer。在
相关问题 更多 >
编程相关推荐