ljean / modbus-tk

Create Modbus app easily with Python
Other
569 stars 213 forks source link

The global lock can be replaced by `self.lock` in `Master.execute` #165

Open sazima opened 2 years ago

sazima commented 2 years ago

https://github.com/ljean/modbus-tk/blob/c168f7158abd16d487046eaecb2aa49bf863d9dd/modbus_tk/modbus.py#L137

In my project, I need to read more than a dozen PLCs and each Plc needs to read 60 address. When I read one PLC, it is not necessary for the other Plc to wait for lock.

In my test: When use @threadsafe_function call execute cost more than 20 seconds every time . Use with self.lock: takes only cost less than 1 seconds