def from_func_code(fut, func_code, data):
if func_code & 0x80:
fut.set_exception(modbus_exception_codes[data[0]])
else:
try:
fut.set_result(function_codes[func_code](data))
except BaseException as e:
fut.set_exception(e)
Here we set a future without checking if the future is done.
This can cause an invalid state error when a task is cancelled before processing a response
Here we set a future without checking if the future is done. This can cause an invalid state error when a task is cancelled before processing a response