import asyncio from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync from sqlalchemy.ext.asyncio import AsyncSession from influx_related import get_influx_data from models.execution.model_execution import ExecutionModel from utils.db.db_execution import ExecutionQueryAsync loop_stop_label: bool = True async def internal_loop_stop(task: asyncio.Task) -> None: print("Stopping main Loop") loop = asyncio.get_event_loop() global loop_stop_label loop_stop_label = False try: await task print("Cancelled") except asyncio.CancelledError: print("Cancelled exception") pass async def internal_loop(influxdb_client: InfluxDBClientAsync, mysql_client: AsyncSession): i = 0 global loop_stop_label while loop_stop_label: print("internal_loop", loop_stop_label, i) i += 1 try: records = await get_influx_data(influxdb_client) print("influx records:", len(records)) [print(" -", i) for i in records] except Exception as e: print(e) print(f"{type(mysql_client)=}") # print(f"{type(mysql_client())=}") execution_query = ExecutionQueryAsync(mysql_client) 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(5)