2014-10-30 70 views
0

当Web2py变得可用时,它有可能将数据写入响应中吗? 例如,我有一个非常长时间运行的函数,它将进度写入响应。 我希望它的输出在打印时立即显示,而不是在整个函数结束时显示。Web2py中的非缓冲输出响应

回答

2

退房这个简单的例子我写的,它可以帮助,对我的作品

 
#The process to run (print the tablenames) 
def process(db): 
    for tablename in db.tables: 
     for i in range(int(1e5)): pass #Simulate long task for the table 
     yield "%s is ready! <br/>" % tablename #Table result 

#You call this 
def test(): 
    return process(db) #Returning the generator streams the individual results