Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flask config.py与';如果';关于烧瓶的声明_Flask_Celery - Fatal编程技术网

Flask config.py与';如果';关于烧瓶的声明

Flask config.py与';如果';关于烧瓶的声明,flask,celery,Flask,Celery,在flask中的config.py文件中使用if语句是否有可能会遇到问题?我见过一些这样做的例子,但也许我做错了什么,因为芹菜不识别“芹菜结果”后端 class Config(object): if 'VCAP_SERVICES' in os.environ: print('Vcap detectado', file=sys.stdout) REDIS_URL = os.environ.get('REDIS_BASE_URL').format(cer

在flask中的config.py文件中使用if语句是否有可能会遇到问题?我见过一些这样做的例子,但也许我做错了什么,因为芹菜不识别“芹菜结果”后端

class Config(object):

    if 'VCAP_SERVICES' in os.environ:

        print('Vcap detectado', file=sys.stdout)

        REDIS_URL = os.environ.get('REDIS_BASE_URL').format(cert_type='required') 

        CELERY_BROKER_URL = os.environ.get('REDIS_BASE_URL').format(cert_type='CERT_REQUIRED') 

    else:

        REDIS_URL = 'redis://'

        CELERY_BROKER_URL = 'redis://localhost:6379/0'


    CELERY_RESULT_BACKEND = CELERY_BROKER_URL
----更新----

芹菜给我带来的错误是这个,但很少有时候我会遇到这个错误,其他的AsyncResult可以正常工作:

AttributeError: 'DisabledBackend' object has no attribute '_get_task_meta_for'

从我的研究中,我发现没有人这样做,这是一种不好的做法,更干净的做法是使用config.py和基本配置进行测试,然后为我的服务器创建antother

app.config.from_object('yourapplication.default_settings')
app.config.from_envvar('YOURAPPLICATION_SETTINGS')

现在添加第二行代码,我只需在服务器中设置新的env变量,我有两个干净的文件及其配置变量

会出现什么错误?更新了帖子