pazzarpj / aiomodbus

Asyncio Library for Modbus
MIT License
5 stars 1 forks source link

Serial client can hang waiting for read #14

Closed pazzarpj closed 4 years ago

pazzarpj commented 4 years ago

A case with Siemans IOT2040 box reading from an ABB M2M on 19200 baud. The M2M is giving unreliable reads with missing requests and CRC errors on both aiomodbus and pymodbus. Both async clients hang the task in the event loop. Aiomodbus does not raise it's TimeoutError. I'm finding it hard to reproduce in an isolated environment. The line of code it hangs in serial.py

   -->        await asyncio.wait_for(self.evt.wait(), 0.01)
                timeout = 0
            except TimeoutError:
                timeout += 0.01
                if timeout >= 0.1:
                    raise

Potentially a race condition with self.evt.wait already being set before waiting is occurring?