Skip to content

Commit

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

async def _connect(self) -> None:
"""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: int, count):
"""Read modbus output coils (0 address prefix)."""
Expand Down

0 comments on commit e0b45d8

Please sign in to comment.