def deferToThread(self, callback, func, *args, **kw):
"""
Defer a function to a thread and callback the return value.
@type callback: function
@param callback: function to call on completion
@type cbargs: tuple or list
@param cbargs: arguments to get supplied to the callback
@type func: function
@param func: function to call
"""
def f(func, callback, *args, **kw):
ret = func(*args, **kw)
self.setTimeout(0, callback, ret)
threading._start_new_thread(f, (func, callback) + args, kw)
####
# Scheduling
####
评论列表
文章目录