I use django-celery. I need to upload a large video file. I want to update my database when the file completes the download. Is there a way to add a callback that will call the django code and not another task when the task completes? My perfect code would look like this ...
from video.tasks import video_download
from video.models import Video
def my_callback(v):
v.status = "downloaded"
v.save()
def download_http(request):
v = Video.objects.latest().id
a = video_download.delay(v, my_callback)
If there is another way to update the object after completing the celery task, I will also be interested.
PS: I tried to switch to v = Video.objects.latest()instead v = Video.objects.latest().id, so I could just update the instance along the way, but the celery didn't like it because it was an object, not a string. Although it did not a.readyreturn any errors, every time I called , it returned False.
source
share