2
2

More than 5 years have passed since last update.

celery/kombu メモ

Last updated at Posted at 2015-08-01

kombu.utils.symbol_by_name()

文字列で指定したモジュールを import する

>>> import kombu.utils
>>> kombu.utils.symbol_by_name('argparse')
<module 'argparse' from '/Users/sximada/.anyenv/envs/pyenv/versions/3.4.2/lib/python3.4/argparse.py'>

セミコロンを使ってモジュール内にあるobjectを取得する

>>> kombu.utils.symbol_by_name('argparse:ArgumentParser')
<class 'argparse.ArgumentParser'>

celery.utils.instantiate()

文字列で指定したobjectをインスタンス化する

>>> import celery.utils
>>> celery.utils.instantiate('argparse:ArgumentParser', description='test')
ArgumentParser(prog='', usage=None, description='test', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)

kombu.utils.cached_property()

propertyのcache。reifyみたいな感じ。

コネクションプール

redisを使う場合、デフォルトではredis.ConnectionPool()が使われる。
なので接続タイミングはredisのconnectionを取得する際にpool.get_connetion()するタイミングでコネクションが足りなければmake_connection()により作成される。

applicationの引き継ぎの流れ

  1. CLIパラメータで Celery() object名(--appで指定)とceleryコマンド(第一引数)を指定
  2. celery.bin.celery.CeleryCommand() のコンストラクタでappプロパティが設定される
  3. celery.bin.celery.CeleryCommand.execute() 内で第一引数に対応するコマンドを取得して、インスタンス化する際にapp objectを渡す
2
2
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
2
2