question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

100% CPU use of libgpiod_pulsein on Raspberry Pi

See original GitHub issue

Trying 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:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:30 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
makermelissacommented, May 7, 2020

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. 😃

2reactions
MaximKeegancommented, Jan 19, 2020

Same issue on rpi4

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found