38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
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
|
|
|
|
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
|
|
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)
|