Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3494422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:00:13+00:00 2026-05-18T12:00:13+00:00

I am writing a small Django application and I should be able to create

  • 0

I am writing a small Django application and I should be able to create
for each model object its periodical task which will be executed with
a certain interval. I’m use for this a Celery application, but i can’t understand one thing:

class ProcessQueryTask(PeriodicTask):
   run_every = timedelta(minutes=1)

   def run(self, query_task_pk, **kwargs):
       logging.info('Process celery task for QueryTask %d' %
query_task_pk)
       task = QueryTask.objects.get(pk=query_task_pk)
       task.exec_task()
       return True

Then i’m do following:

>>> from tasks.tasks import ProcessQueryTask
>>> result1 = ProcessQueryTask.delay(query_task_pk=1)
>>> result2 = ProcessQueryTask.delay(query_task_pk=2)

First call is success, but other periodical calls returning the error
– TypeError: run() takes exactly 2 non-keyword arguments (1 given) in
celeryd server.
Can I pass own params to PeriodicTask run()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T12:00:14+00:00Added an answer on May 18, 2026 at 12:00 pm

    This was answered wonderfully by Ask Solem in his response to your question on the celery-users Google group.

    Periodic tasks doesn’t use arguments, so you need to make several
    classes or make a periodic task that processes more than one “model”.

    E.g.:

    from celery.task import PeriodicTask
    from celery.decorators import periodic_task
    
    # base class
    class BaseProcessQueryTask(PeriodicTask):
        abstract = True
        run_every = timedelta(minutes=1)
        query_task_pk  = None
    
        def run(self):
            task = QueryTask.objects.get(pk=self.query_task_pk)
            task.exec_task()
    
    class ProcessQueryTask1(BaseProcessQueryTask):
        query_task_pk = 1
    
    class ProcessQueryTask2(BaseProcessQueryTask):
        query_task_pk = 2
    

    but it’s more likely you want something like this:

    @task(ignore_result=True)
    def execute_query_task(task):
        task.exec_task()
    
    @periodic_task(run_every=timedelta(minutes=1))
    def process_query_tasks():
        for task in QueryTask.objects.all():
            ExecuteQueryTask.delay(task)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small tool in C# which will need to send and receive
I'm writing a small application in VB.NET and I would like some of the
I'm writing a small agent in java that will play a game against other
I am writing a small app which I need to test with utf-8 characters
I am writing small social application. One of the features is to write user
I have started learning Python by writing a small application using Python 3.1 and
I'm currently writing a small python app that embeds cherrypy and django using py2app.
I'm writing an iPhone application that needs to send small bits of information (two
I'm writing a small Bittorrent tracker on top of the Django framework, as part
I'm writing a small Django-based frontend to collect and graph internet usage statistics. Currently,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.