简体   繁体   中英

celery beat fail when using djcelery schedule

I have a bit of a challenge and wonder if someone can help. I don't have any problem running celery manually,however if I use the beat with djcelery scheduler, I get a bunch of database errors.

worker: Warm shutdown (MainProcess)

(environment) [root@pse apps]# celery -A services_backend beat -l debug --max-interval=10


celery beat v3.1.26.post2 (Cipater) is starting.


__    -    ... __   -        _


Configuration ->


    . broker -> redis://localhost:6379//


    . loader -> celery.loaders.app.AppLoader


    . scheduler -> djcelery.schedulers.DatabaseScheduler





    . logfile -> [stderr]@%DEBUG
    . maxinterval -> 10.00 seconds (10.0s)
[2020-03-24 01:46:42,962: DEBUG/MainProcess] Setting default socket timeout to 30
[2020-03-24 01:46:42,964: INFO/MainProcess] beat: Starting...
[2020-03-24 01:46:42,964: DEBUG/MainProcess] DatabaseScheduler: intial read
[2020-03-24 01:46:42,964: INFO/MainProcess] Writing entries (0)...
[2020-03-24 01:46:42,964: CRITICAL/MainProcess] beat raised exception <class 'AttributeError'>: AttributeError("'DatabaseFeatures' object has no attribute 'autocommits_when_autocommit_is_off'",)
Traceback (most recent call last):
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/kombu/utils/_init__.py", line 323, in __get_
    return obj.__dict__[self.__name__]
KeyError: 'scheduler'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/apps/beat.py", line 112, in start_scheduler
    beat.start()
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/beat.py", line 470, in start
    humanize_seconds(self.scheduler.max_interval))
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/kombu/utils/_init__.py", line 325, in __get_
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/beat.py", line 512, in scheduler
    return self.get_scheduler()
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/beat.py", line 507, in get_scheduler
    lazy=lazy)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/utils/imports.py", line 53, in instantiate
    return symbol_by_name(name)(*args, **kwargs)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/djcelery/schedulers.py", line 161, in _init_
    Scheduler.__init__(self, *args, **kwargs)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/celery/beat.py", line 185, in _init_
    self.setup_schedule()
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/djcelery/schedulers.py", line 169, in setup_schedule
    self.install_default_entries(self.schedule)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/djcelery/schedulers.py", line 263, in schedule
    self.sync()
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/djcelery/schedulers.py", line 217, in sync
    with commit_on_success():
  File "/usr/lib64/python3.6/contextlib.py", line 81, in _enter_
    return next(self.gen)
  File "/opt/pse/apps/environment/lib/python3.6/site-packages/djcelery/db.py", line 52, in commit_on_success
    if connection.features.autocommits_when_autocommit_is_off:
AttributeError: 'DatabaseFeatures' object has no attribute 'autocommits_when_autocommit_is_off'

I'm using the following versions:-

  1. Django - 3.0.3
  2. Celery 3.1.26.post2
  3. django-celery 3.3.1
  4. redis 3.4.1

Thanks

I faced the same error, and I solved it by changing Django version pip install Django==2.1.8 . By the way, the python versoin should be less than 3.7, if you use python >= 3.7.x , it will return a syntaxerror("async" is a keyword).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM