Compare commits

..

5 Commits

Author SHA1 Message Date
Stefan Allius
2a5266dfd6 catch socket.gaierror exception 2025-07-15 20:52:24 +02:00
Stefan Allius
dcc3fe67a5 Merge branch 'main' of https://github.com/s-allius/tsun-gen3-proxy into s-allius/issue472 2025-07-15 20:32:30 +02:00
Stefan Allius
c12b224414 Update dependency coverage to v7.9.2 2025-07-15 20:21:05 +02:00
Stefan Allius
c5675fea6e Merge branch 'main' of https://github.com/s-allius/tsun-gen3-proxy into renovate/coverage-7.x 2025-07-15 20:16:20 +02:00
renovate[bot]
8625fd06ad Update dependency coverage to v7.9.2 2025-07-03 13:44:15 +00:00
7 changed files with 11 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python 3.13
uses: actions/setup-python@v6
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies

View File

@@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]
- Update dependency pytest-asyncio to v1.1.0
- save task references, to avoid a task disappearing mid-execution
- catch socket.gaierror exception and log this with info level
- Update dependency coverage to v7.9.2
- add-on: bump base-image to version 18.0.3

View File

@@ -1,6 +1,6 @@
flake8==7.3.0
pytest==8.4.1
pytest-asyncio==1.1.0
pytest-asyncio==1.0.0
pytest-cov==6.2.1
python-dotenv==1.1.1
mock==5.2.0

View File

@@ -327,7 +327,6 @@ class SolarmanV5(SolarmanBase):
self.sensor_list = 0
self.mb_regs = [{'addr': 0x3000, 'len': 48},
{'addr': 0x2000, 'len': 96}]
self.background_tasks = set()
'''
Our puplic methods
@@ -340,7 +339,6 @@ class SolarmanV5(SolarmanBase):
self.inverter = None
self.switch.clear()
self.log_lvl.clear()
self.background_tasks.clear()
super().close()
def send_start_cmd(self, snr: int, host: str,
@@ -692,10 +690,8 @@ class SolarmanV5(SolarmanBase):
self.__forward_msg()
def publish_mqtt(self, key, data): # pragma: no cover
task = asyncio.ensure_future(
asyncio.ensure_future(
Proxy.mqtt.publish(key, data))
self.background_tasks.add(task)
task.add_done_callback(self.background_tasks.discard)
def get_cmd_rsp_log_lvl(self) -> int:
ftype = self.ifc.rx_peek()[self.header_len]

View File

@@ -39,7 +39,6 @@ class InverterBase(InverterIfc, Proxy):
self.use_emulation = False
self.__ha_restarts = -1
self.remote = StreamPtr(None)
self.background_tasks = set()
ifc = AsyncStreamServer(reader, writer,
self.async_publ_mqtt,
self.create_remote,
@@ -74,7 +73,6 @@ class InverterBase(InverterIfc, Proxy):
if self.remote.ifc:
self.remote.ifc.close()
self.remote.ifc = None
self.background_tasks.clear()
async def disc(self, shutdown_started=False) -> None:
if self.remote.stream:
@@ -139,10 +137,7 @@ class InverterBase(InverterIfc, Proxy):
logging.info(f'[{self.remote.stream.node_id}:'
f'{self.remote.stream.conn_no}] '
f'Connected to {addr}')
task = asyncio.create_task(
self.remote.ifc.client_loop(addr))
self.background_tasks.add(task)
task.add_done_callback(self.background_tasks.discard)
asyncio.create_task(self.remote.ifc.client_loop(addr))
except (ConnectionRefusedError,
TimeoutError,

View File

@@ -43,7 +43,6 @@ class ModbusTcp():
def __init__(self, loop, tim_restart=10) -> None:
self.tim_restart = tim_restart
self.background_tasks = set()
inverters = Config.get('inverters')
batteries = Config.get('batteries')
@@ -55,13 +54,10 @@ class ModbusTcp():
and 'client_mode' in inv):
client = inv['client_mode']
logger.info(f"'client_mode' for Monitoring-SN: {inv['monitor_sn']} host: {client['host']}:{client['port']}, forward: {client['forward']}") # noqa: E501
task = loop.create_task(
self.modbus_loop(client['host'],
client['port'],
inv['monitor_sn'],
client['forward']))
self.background_tasks.add(task)
task.add_done_callback(self.background_tasks.discard)
loop.create_task(self.modbus_loop(client['host'],
client['port'],
inv['monitor_sn'],
client['forward']))
async def modbus_loop(self, host, port,
snr: int, forward: bool) -> None:

View File

@@ -218,7 +218,6 @@ app = Quart(__name__,
static_folder='web/static')
app.secret_key = 'JKLdks.dajlKKKdladkflKwolafallsdfl'
app.jinja_env.globals.update(url_for=url_for)
app.background_tasks = set()
server = Server(app, __name__ == "__main__")
Web(app, server.trans_path, server.rel_urls)
@@ -269,13 +268,9 @@ async def startup_app(): # pragma: no cover
for inv_class, port in [(InverterG3, 5005), (InverterG3P, 10000)]:
logging.info(f'listen on port: {port} for inverters')
task = loop.create_task(
asyncio.start_server(lambda r, w, i=inv_class:
handle_client(r, w, i),
'0.0.0.0', port))
app.background_tasks.add(task)
task.add_done_callback(app.background_tasks.discard)
loop.create_task(asyncio.start_server(lambda r, w, i=inv_class:
handle_client(r, w, i),
'0.0.0.0', port))
ProxyState.set_up(True)
@@ -299,7 +294,6 @@ async def handle_shutdown(): # pragma: no cover
await inverter.disc(True)
logging.info('Proxy disconnecting done')
app.background_tasks.clear()
await Proxy.class_close(loop)