100% CPU use of libgpiod_pulsein on Raspberry Pi
See original GitHub issueTrying to access a DHT22 sensor from a Raspberry Pi 4 using adafruit_dht
and therefore this library, I observe 100% CPU use of the process libgpiod_pulsein
.
Simple reproducer:
#!/usr/bin/env python3
import adafruit_dht
import board
import time
pin=board.D2
dht_device = adafruit_dht.DHT22(pin)
time.sleep(3600)
This issue was already mentioned in https://github.com/adafruit/Adafruit_Blinka/issues/140#issuecomment-526713507 but I think it deserves its own bug report.
Attaching strace to the busy libgpiod_pulsein process shows the following messages in a high frequency:
ioctl(4, GPIOHANDLE_GET_LINE_VALUES_IOCTL, 0xbea2b1cc) = 0
gettimeofday({tv_sec=1577794452, tv_usec=413127}, NULL) = 0
msgrcv(32768, 0xbea2b37c, 4096, 1, IPC_NOWAIT) = -1 ENOMSG (No message of desired type)
Interestingly, the sensor readout itself works well. Also the deprecated https://github.com/adafruit/Adafruit_Python_DHT library does not show this problem.
I’m running the most recent version of raspbian. libgpiod2 is installed in version 1.2-3+rpi1.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:30 (15 by maintainers)
Top Results From Across the Web
Avoiding 100% CPU usage - Raspberry Pi Forums
I guess the NOP instruction will use very little of the CPU's power. There are no register moves involved. No calculations.
Read more >100% processor usage with WHILE loop in Raspberry Pi
I think your problem is that when motion is detected the loop runs at full speed. I would suggest one of the following...
Read more >CircuitPython Libraries on Linux and the NVIDIA Jetson Nano
For example, on Raspberry Pi we use the python RPi.GPIO library. ... For example, on the Jetson Nano we use the python libgpiod...
Read more >99% CPU usage? Avoid disaster by monitoring the Raspberry Pi
All of this means that a constant really high CPU usage could shorten the life span of the Pi and will definitely mean...
Read more >CircuitPython Libraries on any Computer with MCP2221 ...
4 Overview This guide will show you how to use an MCP2221(A) to connect to I2C ... For example, on linux it will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it was making any progress. I mean from what I can tell, it looks good, it just needs to be packaged up, so thanks for poking. @jamespoore. 😃
Same issue on rpi4