龙卷风通用协同程序一般助教

2024-10-01 17:32:26 发布

您现在位置:Python中文网/ 问答频道 /正文

refresh()可以从main()调用,另一方面refreshloop()看起来没有启动。我希望refreshloop()定期调用refresh()。我做错什么了?在

count = 0
mainloop = tornado.ioloop.IOLoop.instance()
stoprloop = False

@gen.coroutine
def refreshloop(interval):
    global mainloop
    count += 1
    print "here  #" + str(count)
    next_time = mainloop.current().time()
    while (stoprloop == False):
        next_time += int(interval)
        refresh()
        while next_time <= mainloop.current().time():
            next_time += int(interval)
        yield gen.Task(mainloop.current().call_at, next_time)

def main():
    global mainloop

    ...

    refresh()
    refreshloop(5)
    mainloop.start()


if __name__ == '__main__':
    main()

在这方面,

谢谢你们!在

导入的脚本仅在本地可用,因此未显示结果错误。在

在这方面,

两种解决方案似乎都能完美地工作:)。在

^{pr2}$

Tags: falsetimemaindefcountcurrentglobalrefresh

热门问题