def promise_executor_job(job, promise):
"""
Toil job that runs a promise with an executor. Executes the executor and
rejects/resolves the promise.
Returns the promise's success result and error, as a pair.
"""
executor = dill.loads(promise.executor_dill)
# Run the executor, and handle resolution/rejection, possibly scheduling
# child jobs
executor(lambda result: promise.handle_resolve(job, result),
lambda err: promise.handle_reject(job, err))
# Grab the cached result and return it
return (promise.result, promise.err)
评论列表
文章目录