From c6e9a886ab93b8a3d3e5844ba7948fb6d4475a70 Mon Sep 17 00:00:00 2001 From: Amit Ran Date: Mon, 25 Oct 2021 20:54:41 +0300 Subject: [PATCH] Use gettempdir, respecting tempdir enviroment variables --- airflow/utils/db.py | 3 ++- airflow/www/app.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/airflow/utils/db.py b/airflow/utils/db.py index fc0dc44c1db59..16247e0965ed4 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -18,6 +18,7 @@ import logging import os import time +from tempfile import gettempdir from typing import Iterable from sqlalchemy import Table, exc, func, inspect, or_, text @@ -508,7 +509,7 @@ def create_default_connections(session=None): Connection( conn_id="sqlite_default", conn_type="sqlite", - host="/tmp/sqlite_default.db", + host=os.path.join(gettempdir(), "sqlite_default.db"), ), session, ) diff --git a/airflow/www/app.py b/airflow/www/app.py index 2de041ba25966..efafcd9ede834 100644 --- a/airflow/www/app.py +++ b/airflow/www/app.py @@ -18,6 +18,7 @@ # import warnings from datetime import timedelta +from tempfile import gettempdir from typing import Optional from flask import Flask @@ -113,7 +114,7 @@ def create_app(config=None, testing=False): init_robots(flask_app) - Cache(app=flask_app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp'}) + Cache(app=flask_app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': gettempdir()}) init_flash_views(flask_app)