This change gives the caller the ability to override the @threadsafe_function decorator by calling the decorated function, like execute(), with the kwarg 'threadsafe=False'. This is useful when the client code is managing multiple modbus.Master instances, each in their own thread, and wants to avoid the global locking that takes place.
Here is psuedocode of what I am executing without error:
def modbus_worker(modbus_master):
result = modbus_master.execute(..., threadsafe=False)
print(result)
modbus_threads = []
for ip, port in devices:
master = modbus_tcp.Master(host=ip, port=port)
t = threading.Thread(target=modbus_worker, args=(master,))
modbus_threads.append(t)
t.start()
The default behavior is unchanged. Callers must include the new 'threadsafe' kwarg to avoid locking.
This change gives the caller the ability to override the @threadsafe_function decorator by calling the decorated function, like execute(), with the kwarg 'threadsafe=False'. This is useful when the client code is managing multiple modbus.Master instances, each in their own thread, and wants to avoid the global locking that takes place.
Here is psuedocode of what I am executing without error:
The default behavior is unchanged. Callers must include the new 'threadsafe' kwarg to avoid locking.