美文网首页
tornado finish() called twice

tornado finish() called twice

作者: 邪恶的奥伯伦 | 来源:发表于2018-11-13 16:56 被阅读0次
    raise RuntimeError("finish() called twice.  May be caused "
    RuntimeError: finish() called twice.  May be caused by using async operations without the @asynchronous decorator.
    

    这是一个tornado非常基础的问题, finish()之后 server端会主动关闭与client的链接, 但是默认情况下还会继续执行后面的代码,

    比如我们可以放一些异步操作在这里, 虽然我不会这么做...

    所以呢, 如果一个程序在if里 调用了finish() 程序仍然会继续执行到后面, 再次执行一次finish() 就会报这个错,

    正确的作法是在前面的finish()后面加一个return 这样后面的代码就不会继续被执行了

    相关文章

      网友评论

          本文标题:tornado finish() called twice

          本文链接:https://www.haomeiwen.com/subject/pjplfqtx.html