exitsignal func blocked while loop in start method

Moderator: RevPiModIO

Post Reply
emololftw
Posts: 1
Joined: 10 Aug 2021, 20:43

exitsignal func blocked while loop in start method

Post by emololftw »

Dear community,

i love to make my project alive with RevPi. I would like to ask you if my situation is just inaccurate python code or if it is insecure CPU unit behavior. My application collects data into an array and sends it to my api server once every 5 minutes. The data it collects is checked by the DI module on the leading edge. I define them with the as_thread parameter to achieve parallel addition of data to the array (the array is stored in a txt file and then wrapped in json)

this is the way how to define reg_event:

Code: Select all

self.revpi.io[id].reg_event(self.triggerEdge, edge=input, as_thread=True)
in reg_event I'm servicing a txt file and performing calculations. At the end of the method I have a delay of 0.3 sec due to sensor oscillations:

Code: Select all

thread.exit.wait(0.3)
I have a 2 sec delay between each http request. so that they don't go to my server immediately at the same time (now and then it happened that 4/5 requests went out, but I attribute that to the server api)

Code: Select all

self.revpi.exitsignal.wait(2)
my problem is that the while loop in the start method is stuck. I log every key refresh to gather data and it got stuck out of nowhere. I run the program using revpiload configuration and also check the logs. Where at the time of the incident I only had the last generated token (the token is generated every 5 min and the last one was 2 days old).
Example of my start method:

Code: Select all

    def start(self):
        time.sleep(1)
        self.revpi.mainloop(blocking=False)

        while not self.revpi.exitsignal.wait(sendingDataInterval):
            self.prepareBatches()
I am now running a second attempt where the while loop is checked using the .is_set() function, where the first pass of the iteration did not suit me at first but I have adapted the code accordingly. So I would like to respectfully ask you if you have any idea what the problem is. The application behaved perfectly during the test mode. We didn't lose data due to the batching system, but it's annoying. Thank you.

CPU: Kunbus RevPi Core S 8 GB PR100359
MODULES: Kunbus RevPi DI PR100195
Post Reply