特定のタスクを実行するdjangoセロリビューがあり、タスクが正常に完了した後、それをデータベースに書き込みます。
私はこれをやっています:
result = file.delay(password, source12, destination)
と、
if result.successful() is True:
#writes into database
しかし、タスクの実行が終了した後、if条件にはなりません。試してみましresult.ready()
たが、うまくいきませんでした。
編集:上記の行は同じビューにあります:
def sync(request):
"""Sync the files into the server with the progress bar"""
choice = request.POST.getlist('choice_transfer')
for i in choice:
source12 = source + '/' + i
start_date1 = datetime.datetime.utcnow().replace(tzinfo=utc)
start_date = start_date1.strftime("%B %d, %Y, %H:%M%p")
basename = os.path.basename(source12) #Get file_name
extension = basename.split('.')[1] #Get the file_extension
fullname = os.path.join(destination, i) #Get the file_full_size to calculate size
result = file.delay(password, source12, destination)
if result.successful() is True:
#Write into database
e:#データベースへの書き込み