Skip to content

Commit e0f3cf2

Browse files
authored
fix: writer close if connection does not open for tcp strategy (#80)
If the asyncio.open_connection call fails, writer will never be assigned a value, which means the comparison in the finally block will throw an UnboundLocalError. We work around this by just assigning None to writer at the outset This fixes the secondary exception in #79 but not the main problem
1 parent 86d9db6 commit e0f3cf2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

custom_components/venta/venta_strategy.py

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ def _build_message(
153153

154154
async def _send_request(self, message: str) -> dict[str, Any] | None:
155155
"""Request data from the Venta device using TCP protocol."""
156+
writer = None
157+
156158
try:
157159
reader, writer = await asyncio.open_connection(
158160
self._host_definition.host, self._host_definition.port

0 commit comments

Comments
 (0)