我有一个相当复杂的报告生成工作,这需要生成跨越多个表。在excel sheet.The过程中创建最终报告需要10-20分钟。
我们已经为客户端提供了Django web应用程序。仅当客户端请求报告时才会出现问题,我们正在生成一个URL,这需要时间,并且对于UI而言是一个问题。
我希望任务是运行在后面,当结束时,它可以发送给客户一个链接,与报告。什么是正确的策略,以及应该使用的库?
发布于 2011-11-10 19:32:57
你可以使用http://celeryproject.org/,它的工作方式就像一个护身符,它有很好的Django集成,它有很好的文档记录并被很多人使用。
发布于 2011-11-10 21:13:58
下面的程序可能会对你有所帮助。
background.py
import subprocess
def background_execute(command):
# launching the command
p1 = subprocess.Popen(command,shell=True,stdout=True)
p1.wait()
print "Wait over, child exits"
<Here you can add code to send mail>用法:
background_execute(["python sleep.py"])sleep.py
import time
print "I am in sleep script, and will sleep for 10 sec"
time.sleep(10)
print "exit from child"https://stackoverflow.com/questions/8078806
复制相似问题