私のdjangoビューでは、サブプロセスによって起動されたスクリプトがバックグラウンドでいくつかのコマンドを実行しているので電子メール通知を送信する必要があります。どのように私はこれを行うことができるかについてのアイデア?サブプロセスが処理を終了したら実行コード
マイビュー:
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')
https://stackoverflow.com/questions/14043030/checking-status-of-process-with-subprocess-popen-in-python help? – Stael
私はcomunicate()関数でいくつかのエラーを抱えていましたが、答えのコメントにありましたが、とにかくありがとうございます。 –