Correct stop of loop, mysql and influx
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user