diff --git a/src/core/config.py b/src/core/config.py index 9c6a1da..d3dc92c 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -5,7 +5,7 @@ class Settings(BaseSettings): ENV: str DATABASE_URL: str KAFKA_HOST: str - POOL_RECYCLE: int - POOL_TIMEOUT: int + POOL_RECYCLE: int = 25 + POOL_TIMEOUT: int = 25 settings = Settings() \ No newline at end of file diff --git a/src/core/database/database.py b/src/core/database/database.py index 92a90f6..07b7d54 100644 --- a/src/core/database/database.py +++ b/src/core/database/database.py @@ -6,7 +6,13 @@ from src.core.config import settings # Create an async SQLAlchemy engine -engine = create_async_engine(settings.DATABASE_URL, echo=(settings.ENV != "PRD"),pool_pre_ping=True,) +engine = create_async_engine( + settings.DATABASE_URL, + pool_timeout=settings.POOL_TIMEOUT, + pool_recycle=settings.POOL_RECYCLE, + echo=(settings.ENV != "PRD"), + pool_pre_ping=True, +) # Create a session factory SessionFactory = sessionmaker( diff --git a/src/core/logging_config.py b/src/core/logging_config.py index 6eaf651..d9918b7 100644 --- a/src/core/logging_config.py +++ b/src/core/logging_config.py @@ -32,12 +32,12 @@ logging.getLogger("aiomysql").setLevel(logging.ERROR) logging.getLogger("aiokafka").setLevel(logging.WARNING) -if settings.ENV == "PRD": - uvicorn_error = logging.getLogger("uvicorn.error") - uvicorn_error.disabled = True - uvicorn_access = logging.getLogger("uvicorn.access") - uvicorn_access.disabled = True - -# https://github.com/aio-libs/aiomysql/issues/103 -# https://github.com/coleifer/peewee/issues/2229 -warnings.filterwarnings("ignore", ".*Duplicate entry.*") +# if settings.ENV == "PRD": +# uvicorn_error = logging.getLogger("uvicorn.error") +# uvicorn_error.disabled = True +# uvicorn_access = logging.getLogger("uvicorn.access") +# uvicorn_access.disabled = True + +# # https://github.com/aio-libs/aiomysql/issues/103 +# # https://github.com/coleifer/peewee/issues/2229 +# warnings.filterwarnings("ignore", ".*Duplicate entry.*") diff --git a/src/tests/.gitkeep b/tests/.gitkeep similarity index 100% rename from src/tests/.gitkeep rename to tests/.gitkeep