首页 > 解决方案 > 如何在扭曲的另一个延迟线程中使用一个线程函数的结果

问题描述

我的 Twisted 服务器代码:

@app.route("/output", methods=['GET'])
@inlineCallbacks
@authenticate
def predict(request):
    request_params = request.args
    logger.debug("request param are {}".format(request_params))
    output = request_params['text']
    RESPONSE = yield threads.deferToThread(inference,output)
    PTAG = yield threads.deferToThread(tagging,RESPONSE['modified'],pattern1,pattern2)
    RESULT = yield threads.deferToThread(result,RESPONSE['modified'],enco)

现在对于方法标记,我想从第一次产量中使用 RESPONSE 字典的键“修改”。但它似乎比我的同步服务器花费更多的时间

标签: python-3.xasynchronoustwisted.web

解决方案


推荐阅读