I'm using dotenv within a docker celery container.
The container has the code below.
In between runs I change the content of .env1 from
LOGGING_CONF_FILE=logging1.yaml
to LOGGING_CONF_FILE=logging2.yaml
I then touch the file __init__.py
which trigerrs a reload of the app
I expect to see in the console: LOGGING_CONF_FILE10 logging2.yaml
but I still see LOGGING_CONF_FILE10 logging1.yaml
If I touch the file __init__.py
again, which triggers another reload of the app,
I do see in the console: LOGGING_CONF_FILE10 logging2.yaml
as expected.
- Why dotenv isn't picking up the changes in the .env1 file immediately?
- Also, why does "os.unsetenv" and "os.putenv" not unsetting the variable?
When I print the value of LOGGING_CONF_FILE, I'm getting some value (and not undefined on empty string).
Thanks
cat .env1
...
LOGGING_CONF_FILE=logging1.yaml
def create_app(config_class=Config):
print( 'BEG create_app' )
app = Flask(__name__)
# app.app_context().push()
app.config.from_object(config_class)
from app.errors import bp as errors_bp
app.register_blueprint(errors_bp)
db.init_app(app)
mail.init_app(app)
bootstrap.init_app(app)
pagedown.init_app(app)
migrate.init_app(app, db)
# auth = HTTPBasicAuth()
# auth_token = HTTPBasicAuth()
login.init_app(app)
class ContextTask(celery.Task):
def __call__(self, *args, **kwargs):
with app.app_context():
return self.run(*args, **kwargs)
celery.conf.update(app.config)
celery.Task = ContextTask
...