0

i try to execute background function using celery: this is my current code :

from VideoPublish.models import TitleVideo, Videos
from celery.decorators import task
from UploadExpert.celery import app

# Create your views here.

demo_titles =['title1', 'title2', 'title3']


@app.task(ignore_result=True)
def GetTitles(video_id):
    video = Videos.objects.get(pk=video_id)

    for title in demo_titles:
        t = TitleVideo(
            title=title,
            video_id=video.id
            )
        t.save()

this is call function :

GetTitles.delay(video_id=obj.id)

and this is a celery error:

https://gist.github.com/scaltro/cc6152f82b0fbf501af396b8ad812e91

i want to know where i'am wrong, and how i can solve this problem

krakiun
  • 15
  • 5
  • Please post your celery.py file for us. – 2ps Nov 28 '18 at 21:20
  • @2ps https://gist.github.com/scaltro/ff9c4be0bcccebcd612afee11e352ae0 – krakiun Nov 28 '18 at 21:21
  • Does the same thing happen when you call debug_task? – 2ps Nov 28 '18 at 21:26
  • @2ps, in python not return any error, >>> GetTitles.delay(17) only in celery return error – krakiun Nov 28 '18 at 21:28
  • That wasn't a call in python--using `.delay` queues up the task to be run in celery. If you want to run in python, just use `GetTitles(17)`. But in any case, one last thing, can you please post your `CELERY_*` settings from your settings file? – 2ps Nov 28 '18 at 21:29
  • @2ps with GetTitles(17) same error, this is my settings.py https://pastebin.com/3mFLZfBK – krakiun Nov 28 '18 at 21:35

0 Answers0