2016-12-05 4 views
0

user guideの例に続いて、app.conf.humanize(with_defaults=False)を使ってセロリの設定を出力しようとしています。しかし、私はいつもwith_defaults=Falseを使用して空の文字列を取得しますが、代わりに.humanize(with_defaults=True)を使用して変更を見ることができるので、構成の変更が影響していることがわかります。セロリのapp.conf.humanize(with_defaults = False)のデフォルトと見なされるものは何ですか?

私はそうはデフォルトではありませんように、モジュールmyconfigで設定をロードする方法があり、app.conf.config_from_object('myconfig')で設定を追加すると、「デフォルト」として構成設定をロードしていることを推測していますか?

は、これは私のソースコードです:

#myconfig.py 
worker_redirect_stdouts_level='INFO' 
imports = ('tasks',) 

#tasks.py 
from celery import Celery 

app = Celery() 
app.config_from_object('myconfig')  
print "config: %s" % app.conf.humanize(with_defaults=False) 

@app.task 
def debug(*args, **kwargs): 
    print "debug task args : %r" % (args,) 
    print "debug task kwargs: %r" % (kwargs,) 

私はenv PYTHONPATH=. celery worker --loglevel=INFOを使用してセロリを開始し、それは(私がwith_defaults=Trueに変更した場合、私は期待される全出力を得る)config:を出力します。

+0

私はそれ以来、[バグレポート](https://github.com/celery/celery/issues/3652)に提出されました'human.conf( 'worker_redirect_stdouts_level')'の項目の1つにアクセスした後、 'humanize() – ecerulm

答えて

0

config_from_object()またはconfig_from_envvar()がロードされた設定は、デフォルトとはみなされません。

観察された動作は、bug reportに対応するthis commitで修正されたバグが原因で、将来のバージョンのセロリが期待どおりに動作するようになりました。

myconfigPYTHONPATHでPythonモジュールである
from celery import Celery 
app = Celery 
app.config_from_object('myconfig') 
app.conf.humanize() # returns only settings directly set by 'myconfig' omitting defaults 

#myconfig.py 
worker_redirect_stdouts_level='DEBUG' 
関連する問題