In my django view, i need to send email notification after subprocess is done because the script launched by subprocess is running some commands in background so the email is sent before the script is done, does anyone have an idea about how i could do this ?
My view:
def getor(request):
# process
subprocess.call("./step1.sh", shell=True)
#send notification
current_site = get_current_site(request)
user = User.objects.values('username').order_by('id').last()
us = user['username']
subject = 'Notification of endprocess.'
message = render_to_string('notify.html', {
'us':us,
'domain':current_site.domain,
})
eml = User.objects.values('email').order_by('id').last()
toemail = eml['email']
email = EmailMessage(subject, message, to=[toemail])
email.send()
return render(request, 'endexecut.html')