Proxy counters don't work after restart properly

Fixes #21
This commit is contained in:
Stefan Allius
2023-11-01 21:08:51 +01:00
parent bcd37faa4f
commit 387bab01be

View File

@@ -3,8 +3,6 @@ from logging import config
from async_stream import AsyncStream from async_stream import AsyncStream
from inverter import Inverter from inverter import Inverter
from config import Config from config import Config
from mqtt import Mqtt
from infos import Infos
async def handle_client(reader, writer): async def handle_client(reader, writer):
@@ -68,11 +66,7 @@ if __name__ == "__main__":
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop) asyncio.set_event_loop(loop)
# call Mqtt singleton to establisch the connection to the mqtt broker Inverter.class_init()
mqtt = Mqtt()
# initialize the proxy statistics
Infos.static_init()
# #
# Register some UNIX Signal handler for a gracefully server shutdown on Docker restart and stop # Register some UNIX Signal handler for a gracefully server shutdown on Docker restart and stop
# #
@@ -90,9 +84,7 @@ if __name__ == "__main__":
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
finally: finally:
logging.info ('Close MQTT Task') Inverter.class_close(loop)
loop.run_until_complete(mqtt.close())
mqtt = None # release the last reference to the singleton
logging.info ('Close event loop') logging.info ('Close event loop')
loop.close() loop.close()
logging.info (f'Finally, exit Server "{serv_name}"') logging.info (f'Finally, exit Server "{serv_name}"')