Skip to content

Commit

Permalink
Remove lock on connect (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 authored Sep 12, 2023
1 parent 59ba2cd commit b7bb215
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions watlow/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ def _detect_pymodbus_version(self) -> None:

async def _connect(self):
"""Start asynchronous reconnect loop."""
async with self.lock:
try:
if self.pymodbus30plus:
await asyncio.wait_for(self.client.connect(), timeout=self.timeout) # 3.x
else: # 2.4.x - 2.5.x
await self.client.start(self.ip) # type: ignore
except Exception:
raise OSError(f"Could not connect to '{self.ip}'.")
try:
if self.pymodbus30plus:
await asyncio.wait_for(self.client.connect(), timeout=self.timeout) # 3.x
else: # 2.4.x - 2.5.x
await self.client.start(self.ip) # type: ignore
except Exception:
raise OSError(f"Could not connect to '{self.ip}'.")

async def read_coils(self, address, count):
"""Read modbus output coils (0 address prefix)."""
Expand Down

0 comments on commit b7bb215

Please sign in to comment.