Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Leaking open files when running gpiod.find_line() #32

Open
karlbackstrom opened this issue Mar 26, 2023 · 0 comments
Open

Leaking open files when running gpiod.find_line() #32

karlbackstrom opened this issue Mar 26, 2023 · 0 comments

Comments

@karlbackstrom
Copy link

This is a small step-by-step to reproduce the error:

  • Have a named pin on any chip above gpiochip0.
  • Run this code, substitute the GPIO_NAME:
import gpiod
for i in range(1025):
  a = gpiod.find_line("GPIO_NAME")

This results in an error about too many open files.
Error:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib/python3.10/site-packages/gpiod/__init__.py", line 48, in find_line
  File "/usr/lib/python3.10/site-packages/gpiod/libgpiodcxx/__init__.py", line 1285, in __iter__
  File "/usr/lib/python3.10/site-packages/gpiod/libgpiod/__init__.py", line 1195, in __iter__
  File "/usr/lib/python3.10/site-packages/gpiod/libgpiod/__init__.py", line 118, in gpiod_chip_open
  File "/usr/lib/python3.10/site-packages/gpiod/libgpiod/__init__.py", line 89, in _is_gpiochip_cdev
OSError: [Errno 24] Too many open files: '/sys/bus/gpio/devices/gpiochip0/dev'

Potential reason is that find_line doesn't properly close file descriptors when going through the chips. Can not reproduce on gpiochip0 or when trying to find a pin that doesn't exists.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant