Well, this is not a Bug. The update of RevPiModIO, which is implemented in 2.4.2, prevents the system from spam the messages. They will appear just one time.
The warning will appear, if a event function takes very long time and another event rises. Long run time of a function could happen with sleep calls or long loops.
Code: Select all
import revpimodio2
import time
def test(name, value):
sleep(1)
print(name, value)
rpi = revpimodio2.RevPiModIO(autorefresh=True)
rpi.handlesignalend()
rpi.io.I_1.reg_event(test)
rpi.mainloop()
This program will run without a warning. If you change state of I_1 to high, the function "test" will be executed and has a run time of about 1 second.
- after 1 second - no warning - Output: "I_1 True"
If you set I_1 to low AFTER 1 second, the function "test" will be executed again.
If you change the state of I_1 after 500 milliseconds to high again, the function "test" should be executed, but it is still running because of the sleep(1) call.
- warning will rise!
- after 500 milliseconds the output "I_1 False" appear
- after 1 second the output "I_1 True" will apper
You see, ALL event functions will be executed exact in the order of rising, but the mainloop will not execute them in parallel. The warning tells you, that there could come problems:
Imagine: If you switch state of I_1 10 times in a second, the mainloop will execute the "test" function 10 times, but this will take 10 seconds. So if you stop trigger the I_1, the program will output "I_1 True / False" 10 seconds after that...
Why should that be good???
Fist, you CAN execute event functions in parallel! You just have to add the "as_thread=True" to the
.reg_event(...) function. Than all functions will be executed at the same time, doesn't matter of the run times.
This could be dangerous on controlling a plant! For example: Your function takes long time and set an output in the end. In the same time another event rises and like to switch off the same output. If this functions are running parallel, the output will be set on the end! So RevPiModIO just wants to warn you to write your code as fast as possible. And if you want long running functions you can use the "as_thread" argument.
I hope my explanation is okay and understandable
Sven