0

セロリをジャンゴで動作させるのに問題があります。セロリを使用して Web サイトをスクレイピングし、いくつかの django モデルを 20 分ごとに更新したいと考えています。

アプリ ディレクトリに更新クラスを持つタスク ファイルを作成しました。

class Update(PeriodicTask):
    run_every=datetime.timedelta(minutes=20)

    def run(self, **kwargs):
        #update models

コマンドラインから実行すると、クラスはモデルを正しく更新します。

if __name__ == '__main__':
    Update().run()

setting.py の私のセロリ設定は次のようになります。

CELERY_RESULT_BACKEND = "database"
BROKER_HOST = 'localhost'
BROKER_PORT = 5672
BROKER_USER = 'Broker'
BROKER_PASSWORD = '*password*'
BROKER_VHOST = 'broker_vhost'

しかし、実行するmanage.py celeryd -v 2と接続エラーが発生します。

[2010-12-29 09:28:15,150: ERROR/MainProcess] CarrotListener: Connection Error: [Errno 111] Connection refused. Trying again in 10 seconds...

私は何が欠けていますか?

アップデート:

既存のデータベースを使用しているため、かなり良さそうなdjango-kombuを見つけました。django-kombu と kombu をインストールしましたが、実行時に次のエラーが発生しますmanage.py celeryd -v 2

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "<webapp_path>/lib/python2.6/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "<webapp_path>/lib/python2.6/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "<webapp_path>/lib/python2.6/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "<webapp_path>/lib/python2.6/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "<webapp_path>/lib/python2.6/django_celery-2.1.4-py2.6.egg/djcelery/management/commands/celeryd.py", line 20, in handle
    worker.run(*args, **options)
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/bin/celeryd.py", line 83, in run
    from celery.apps.worker import Worker
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/apps/worker.py", line 15, in <module>
    from celery.task import discard_all
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/task/__init__.py", line 7, in <module>
    from celery.execute import apply_async
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/execute/__init__.py", line 7, in <module>
    from celery.result import AsyncResult, EagerResult
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/result.py", line 9, in <module>
    from celery.backends import default_backend
  File "<webapp_path>/lib/python2.6/celery-2.1.4-py2.6.egg/celery/backends/__init__.py", line 51, in <module>
    default_backend = DefaultBackend()
TypeError: __init__() takes exactly 2 arguments (1 given)
4

2 に答える 2

1

ブローカーがインストール/実行されているようには見えません (RabbitMQ?)

于 2010-12-30T02:14:42.733 に答える
0

私は同じ問題を抱えていましたが、問題はインポートパスが間違っていたことです。

おそらく、タスクを次のようにインポートします

from celery import task.

あなたがすべき間

from celery.task import task

于 2012-06-12T19:39:26.343 に答える