Cycle time exceeded without using cycleloop() or mainloop()

Moderator: RevPiModIO

Post Reply
RiSpa
Posts: 4
Joined: 24 Mar 2022, 11:14

Cycle time exceeded without using cycleloop() or mainloop()

Post by RiSpa »

Hello,


The following Python script (IP-address is replaced by x's) gives continually repeated warnings resulting from line 5 (

Code: Select all

pass
):

Code: Select all

revpimodio2\helper.py:614: RuntimeWarning: cycle time of 50 ms exceeded - can not hold cycle time!

Code: Select all

import revpimodio2
revpi_ip = "xxx.xxx.xxx.xxx"
rpi = revpimodio2.RevPiNetIO(revpi_ip, autorefresh=True)
while True:
    pass
This occurs due to

Code: Select all

ProcimgWriter
instantiated by

Code: Select all

RevPiNetIO
through

Code: Select all

modio
, which cyclicly reads the IO values from the Revolution Pi.
Simply writing (or reading) an IO instead of performing some task in a while loop works just fine. Most likely because the program is able to finish within the first cycle.
However,

Code: Select all

ProcimgWriter
should be run in a separate thread as I understand. That would mean that the while loop in the above script should not interfere and should not be the cause of any

Code: Select all

RuntimeWarnings
.

Why is this happening and how do I solve it?


Kind regards, any help is appreciated!
User avatar
RevPiModIO
KUNBUS
Posts: 325
Joined: 20 Jan 2017, 08:44
Contact:

Re: Cycle time exceeded without using cycleloop() or mainloop()

Post by RevPiModIO »

Hi RiSpa!

Yes, the ProcimgWriter is a Thread, inside of your python process. Your code:

Code: Select all

while True:
    pass
is using all resources of our process and the ProcimgWriter thread can not hold the cycle time.
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
Post Reply