3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Celery を Python3.7 で使うとき、 backend に redis を指定すると syntax error がでて、動かない。

Posted at

以下のような syntax error が起きてしまい、 backend に redis が指定できない。

[2019-02-07 19:50:49,175: CRITICAL/MainProcess] Unrecoverable error: SyntaxError('invalid syntax', ('$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/backends/redis.py', 22, 19, 'from . import async, base\n'))
Traceback (most recent call last):
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/kombu/utils/objects.py", line 42, in __get__
    return obj.__dict__[self.__name__]
KeyError: 'backend'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/worker/worker.py", line 205, in start
    self.blueprint.start(self)
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/bootsteps.py", line 115, in start
    self.on_start()
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/apps/worker.py", line 139, in on_start
    self.emit_banner()
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/apps/worker.py", line 154, in emit_banner
    ' \n', self.startup_info(artlines=not use_image))),
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/apps/worker.py", line 217, in startup_info
    results=self.app.backend.as_uri(),
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/kombu/utils/objects.py", line 44, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/app/base.py", line 1196, in backend
    return self._get_backend()
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/app/base.py", line 914, in _get_backend
    self.loader)
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/app/backends.py", line 70, in by_url
    return by_name(backend, loader), url
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/app/backends.py", line 50, in by_name
    cls = symbol_by_name(backend, aliases)
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/kombu/utils/imports.py", line 56, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "$HOME/.local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 860, in get_code
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "$HOME/pyvenv/py37/lib/python3.7/site-packages/celery/backends/redis.py", line 22
    from . import async, base
                      ^
SyntaxError: invalid syntax

Python 3.7 から async が予約語になったので、構文エラーが出たようです。

PyPi に登録しているものは、まだ update されていないので、GitHub にあるソースから update してください。(2019-02-07 現在)

pip install --upgrade https://github.com/celery/celery/tarball/master

issues に上がったのが、2018年8月7日あたりで、2018年8月18日にリリースされているのですが、 修正されたのが27日です。残念!!

個人的な予測ですが、 4.2.2 は出さずに、 4.3 になりそうな予感。

いろいろ議論がされていますが、英語がよくわかりません…。


参考:

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?