python - Own params to PeriodicTask run() method in Celery -


I am writing a small application and should be able to create for each model object, which is its periodic work I'm using a celery app for this, but I can not understand one thing:

  class ProcessQueryTask (PeriodicTask): run_every = timedelta (minutes = 1) Def run (self, query_task_pk, ** kwargs): logging.info ('query task% d'% query_task_pk Work of wine) task = QueryTask.objects.get (pk = query_task_pk) task.exec_task () back true  

Then I do the following:

  > Gt; & Gt; Import from Tasks.tasker ProcessQueryTask & gt; & Gt; & Gt; Result1 = ProcessQueryTask.delay (query_task_pk = 1) & gt; & Gt; & Gt; Results 2 = ProcessQueryTask.delay (query_task_pk = 2)  

The first call is the success, but the error is back to the other normal call - TypeError: run (2) Absolutely 2 non-keyword logic (1 given Given) in my server, do I have my parameters peridicuscript run () ? Ask

Ask for a brilliant inquiry on these.

Periodic work does not use logic, so you need to make many classes or perform a periodic task that processes more than one "model".

Example: Import PeriodicTask celery.decorators from celery.task import Avdik_task # base class Besprkriyacotit (Peridayiktsk): Abstract = true running Wali_sbi = timeliness (m = 1) query_task_pk = no runs Dif (self): work = QueryTask.objects.get (pk = self.query_task_pk) task.exec_task () class ProcessQueryTask1 (BaseProcessQueryTask): query_task_pk = 1 square ProcessQueryTask2 (BaseProcessQueryTask): query_task_pk = 2 < P> but if you want to something like this:

  @ task (ignore_result = true) def execute_query_task (work): task.exec_task () @periodic_task (run_e QueryTask.objects.all ( ) For work: ExecuteQueryTask.delay (Work)  
= Very timeliness (m = 1)) def process_query_tasks ():

Comments