Correct stop of loop, mysql and influx

This commit is contained in:
marys
2025-09-26 11:34:12 +02:00
parent c850a07ff0
commit 521c474a17
3 changed files with 43 additions and 20 deletions

View File

@@ -1,17 +1,25 @@
import asyncio
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
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
def internal_loop_stop():
print("Stopping main Loop")
loop = asyncio.get_event_loop()
global loop_stop_label
loop_stop_label = False
async def internal_loop(influxdb_client: InfluxDBClientAsync, mysql_client: AsyncSession):
i = 0
while True:
print("internal_loop", i)
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)
@@ -26,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(5)
await asyncio.sleep(2)