I have a django celery view which do the certain task and after the task has been completed successfully write that in database.
I am doing this:
result = file.delay(password, source12, destination)
And,
if result.successful() is True:
#writes into database
But after the task has finished execution it doesn't enter into the if condition.I tried with result.ready()
but no luck.
Edit: Those above lines are in the same view:
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: #Writes to database