Fix blocking Coroutines when shutdown!

This commit is contained in:
adator
2025-11-20 15:13:36 +01:00
parent e9af3f9155
commit fe4b68e115

View File

@@ -495,11 +495,17 @@ class Base:
async def shutdown(self) -> None:
"""Methode qui va préparer l'arrêt complêt du service
"""
# Stop RpcServer if running
await self.Loader.RpcServer.stop_server()
# unload modules.
self.logs.debug(f"=======> Unloading all modules!")
for module in self.Loader.ModuleUtils.model_get_loaded_modules().copy():
await self.Loader.ModuleUtils.unload_one_module(module.module_name)
self.logs.debug(f"=======> Closing all Coroutines!")
await asyncio.gather(*self.running_asynctasks)
# Nettoyage des timers
self.logs.debug(f"=======> Checking for Timers to stop")
for timer in self.running_timers:
@@ -527,8 +533,6 @@ class Base:
self.running_sockets.remove(soc)
self.logs.debug(f"> Socket ==> closed {str(soc.fileno())}")
await self.Loader.RpcServer.stop_server()
self.db_close()
return None