Sharing client between thread or one client per thread ? #1461
-
Hello, I'm just starting using this very nice package for Modbus and I'm wondering what is the recommended design for my use case: I have several threads that read sensors value with Modbus.
Or if it is better to share the client:
What do you advise ? Also would you recommend using a Async client in this use case ? Thanks for your help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
First of all use async ! ModbusClient is NOT threadsafe so please do not use the same client from multiple threads....instead use asyncio and get a lot better performance. |
Beta Was this translation helpful? Give feedback.
First of all use async !
Secondly, your device probably do not allow many connections, but if it does then you can have 1 client pr thread.
ModbusClient is NOT threadsafe so please do not use the same client from multiple threads....instead use asyncio and get a lot better performance.