2024-07-11, 05:55 AM
Hi
In case if 'none' lcd configured pypilot_hat application consumes 100% CPU.
In class LCD, function create(self) gets in dead cycle without sharing CPU time.
To fix problem around line 304 of hat.py I added sleep(0.1) to let app to share CPU time.
However I do not think we need to run LCD process at all, but simple fix works too.
def create(self):
def process(pipe, config):
import lcd
print('lcd process on', os.getpid())
self.lcd = lcd.LCD(self.hat.config)
self.lcd.pipe = pipe
if self.lcd.use_glut:
from OpenGL.GLUT import glutMainLoop, glutIdleFunc
glutIdleFunc(self.lcd.poll)
glutMainLoop()
else:
while True: <<<<<<<<<<<<<<<<<<<<<
self.lcd.poll() <<<<<<<<<<<<<<<<<<<<<
time.sleep(0.1) <<<< line I have added to resolve 100% CPU dead loop
super(LCD, self).create(process)
In case if 'none' lcd configured pypilot_hat application consumes 100% CPU.
In class LCD, function create(self) gets in dead cycle without sharing CPU time.
To fix problem around line 304 of hat.py I added sleep(0.1) to let app to share CPU time.
However I do not think we need to run LCD process at all, but simple fix works too.
def create(self):
def process(pipe, config):
import lcd
print('lcd process on', os.getpid())
self.lcd = lcd.LCD(self.hat.config)
self.lcd.pipe = pipe
if self.lcd.use_glut:
from OpenGL.GLUT import glutMainLoop, glutIdleFunc
glutIdleFunc(self.lcd.poll)
glutMainLoop()
else:
while True: <<<<<<<<<<<<<<<<<<<<<
self.lcd.poll() <<<<<<<<<<<<<<<<<<<<<
time.sleep(0.1) <<<< line I have added to resolve 100% CPU dead loop
super(LCD, self).create(process)