question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting celery beat error 'SchedulingError: Couldn't apply scheduled task'

See original GitHub issue

Hi, Thank you for writing a useful project for celery.

I am attempting to use this with scheduled tasks that run every minute that are configured in settings.py using celery beat config like below:

CELERYBEAT_SCHEDULE = {
    'check_products': {
      'task': 'com.ixlayer.tasks.check_products', 'schedule': timedelta(minutes=1),
    },
}


However sometimes I get an exception in the process that runs celery beat.

Traceback (most recent call last):
  File "/Users/kowsari/workspace/ixlayer-be/venv/lib/python2.7/site-packages/celery/beat.py", line 222, in apply_entry
    result = self.apply_async(entry, producer=producer, advance=False)
  File "/Users/kowsari/workspace/ixlayer-be/venv/lib/python2.7/site-packages/celery/beat.py", line 328, in apply_async
    entry, exc=exc)), sys.exc_info()[2])
  File "/Users/kowsari/workspace/ixlayer-be/venv/lib/python2.7/site-packages/celery/beat.py", line 320, in apply_async
    **entry.options)
  File "/Users/kowsari/workspace/ixlayer-be/venv/lib/python2.7/site-packages/celery_once/tasks.py", line 99, in apply_async
    raise e
SchedulingError: Couldn't apply scheduled task check_products:

I am using this configuration.

app.conf.ONCE = {
  'backend': 'celery_once.backends.Redis',
  'settings': {
    'url': settings.BROKER_URL,
    'default_timeout': 60 * 60
  }
}

Is this celerybeat getting the AlreadyQueued exception? Or is this something else? Help is much appreciated.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
xuhcccommented, Feb 13, 2019

I had a very similar problem with periodic task, and solution was to add graceful=True to its options:

@shared_task(base=QueueOnce, once={'graceful': True})
def my_task():
    ...

In my case AlreadyQueued exception was invisible due to logging config, so everything looked like a worker not picking up tasks.

0reactions
cameronmaskecommented, Aug 21, 2019

As a workaround, for now, I’d suggest using a pure celery task to trigger celery once task, i.e.

CELERYBEAT_SCHEDULE = {
    'example': {
      'task': 'tasks.scheduled_task', 'schedule': timedelta(minutes=1),
    },
}

@task()
def scheduled_task():
	scheduled_once_task.delay()

@task(base=QueueOnce)
def scheduled_once_task():
	....

I don’t have the bandwidth currently to fix this, but a PR (while it may be tricky, please include a test case for a scheduled task to aid the review) is welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django celery positional arguments celerybeat scheduling error
I'm having trouble getting celerybeat to schedule ...
Read more >
Couldn't apply scheduled task babysit: [Errno 9] Bad file ...
Description of problem: Below exception appear in /var/log/messages every minute Version-Release number of selected component (if ...
Read more >
Source code for celery.beat
This document describes the current stable version of Celery (5.2). For development docs, go here. Source code for celery.beat. """The periodic task scheduler." ......
Read more >
Celery beat error. trying to make sense of it - Google Groups
I had this error below all over my celery beat log file, but I can't understand exactly WHERE/WHAT is the ... SchedulingError: Couldn't...
Read more >
celery.beat 源代码
The task name name = None #: The schedule (run_every/crontab) schedule ... def _error_handler(exc, interval): error('Celerybeat: Connection error: %s.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found