2

I wrote an extended Python program to control an aquaponic system with a Raspberry Pi (explanation in readme.md).

Since some weeks, the program freezes after some hours. When starting, the CPU-percentage of Python3 is 7-8 %, Memory = 3-4%. After freezing Python3 uses 100% of CPU (according to top). The Raspberry Pi doesn't freez, only the program. I tried to find the cause with psutil. The Python-Shell (which prints the psutil attrs) shows CPU 7.6% and memory 3.4% over houres, then it freezes.

Is there a way to find the cause of freezing with psutil or another sys-module?

I pondered, whether the repeated import commands in submodules (which are invoked during the mainloop) could be the trigger. But the documentation of "import" states that no module is imported again, when it is already in memory.

EarlGrey
  • 2,514
  • 4
  • 34
  • 63
  • Impossible to say without more details. I don't know Raspberry PI specifically but there appear to be many standard logging options available see what your code is actually doing: https://www.raspberrypi.org/forums/viewtopic.php?t=90300 – Jon Feb 07 '20 at 17:17
  • What would be the best way to provide some comments on the code? – AMC Feb 07 '20 at 17:36
  • it is a modularized programm. The main program "Aquaponik_Steuerung" implements three dictionaries, creates a window and then goes in a loop, in the form that a function is repeatedly called with the .after method. In each loop submodules are called to read the sensors, triggering actions etc. Each time the needed modueles are imported (own ones and those provided by Python). If you are interested in more details: go to github.com Brazzelhuber/Aquaponik_Steuerung. – Brazzelhuber Feb 10 '20 at 17:20
  • I found the cause for the freeze myself. It was a function to control an ultrasonic sensor for measuring the waterlevel. An endless loop to read the Echo pulse freezed the program since under certain conditions, the echo never came. The way was, to comment out every single module and reactivate it step by step. Thank you for your hints. Especially the logging was new to me. – Brazzelhuber Feb 13 '20 at 13:50

0 Answers0