remove exception catch in stopping phase

This commit is contained in:
marys
2025-09-26 11:53:45 +02:00
parent 433d6a0148
commit c3ac61b02b

16
main.py
View File

@@ -29,15 +29,13 @@ async def startup(fast_api: FastAPI):
print(f"{mysql_engine=}") print(f"{mysql_engine=}")
print("mysql init done") print("mysql init done")
task = asyncio.create_task(internal_loop(influxdb_client, mysql_client)) task = asyncio.create_task(internal_loop(influxdb_client, mysql_client))
try: yield
yield # Shutdown logic
finally: await internal_loop_stop(task)
# Shutdown logic await influxdb_client.close()
await internal_loop_stop(task) mysql_engine = get_mysql_engine()
await influxdb_client.close() await mysql_client.close()
mysql_engine = get_mysql_engine() await mysql_engine.dispose()
await mysql_client.close()
await mysql_engine.dispose()
app = FastAPI(lifespan=startup) app = FastAPI(lifespan=startup)