I have a fairly complex report generating work, which needs to be generated spaning through multiple tables. Final report is created in an excel sheet.The process takes anything between 10-20 minutes.
We have provided a Django web app for the client. Only issue if the client requests for a report, we are generating a URL and this takes time, and is an issue as far as the UI go.
I would like the task to be running behind, and when over, it can mail the client a link, with the report. What is the right strategy, and libraries to be used?
You can use http://celeryproject.org/, it works like a charm, it has nice Django integration, it's very well documented and used by many.
May be the below program helps you.
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>
Usage:
background_execute(["python sleep.py"])
import time
print "I am in sleep script, and will sleep for 10 sec"
time.sleep(10)
print "exit from child"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With