From cf5b486b2a8a7a8d4285ce7e16d7a8c4fb4fc644 Mon Sep 17 00:00:00 2001 From: marys Date: Fri, 26 Sep 2025 11:43:40 +0200 Subject: [PATCH] Correct stop of loop, mysql and influx --- internal_loop.py | 2 +- mysql_related.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal_loop.py b/internal_loop.py index 9a4f92e..d81ad64 100644 --- a/internal_loop.py +++ b/internal_loop.py @@ -34,4 +34,4 @@ async def internal_loop(influxdb_client: InfluxDBClientAsync, mysql_client: Asyn execution_model: list[ExecutionModel] = await execution_query.get_execution_by_id(293) res = [i.asdict() for i in execution_model] print(res[0]['id']) - await asyncio.sleep(2) + await asyncio.sleep(5) diff --git a/mysql_related.py b/mysql_related.py index 90379ed..a6a42e6 100644 --- a/mysql_related.py +++ b/mysql_related.py @@ -1,3 +1,5 @@ +from typing import AsyncGenerator + from sqlalchemy.ext.asyncio import (create_async_engine, AsyncSession, async_sessionmaker, AsyncEngine) @@ -44,7 +46,8 @@ def get_mysql_engine() -> AsyncEngine: def get_mysql_session_local() -> AsyncSession: return mysql_SessionLocal() -async def get_mysql_db(): +async def get_mysql_db() -> AsyncGenerator[AsyncSession]: """FastAPI dependency for providing DB sessions""" async with get_mysql_session_local() as session: - yield session + print(f"{session=}") + yield session