* [libgpiod][PATCH v2] bindings: python: allow releasing a LineRequest multiple times
@ 2026-04-03 15:46 Vincent Fazio
2026-04-07 12:53 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Fazio @ 2026-04-03 15:46 UTC (permalink / raw)
To: linux-gpio; +Cc: brgl, Vincent Fazio
In Python, it is common for objects to allow their `close` method to be
executed multiple times out of convenience. An example of this is the
`IOBase` class [0] which is the base class of most file-like classes.
Update `LineRequest.release` to follow this example as it performs the
same function as `close`.
[0]: https://docs.python.org/release/3.10.0/library/io.html#io.IOBase.close
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/gpiod/line_request.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index 0287791..a271080 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -75,9 +75,9 @@ class LineRequest:
Release this request and free all associated resources. The object must
not be used after a call to this method.
"""
- self._check_released()
- cast("_ext.Request", self._req).release()
- self._req = None
+ if self._req is not None:
+ self._req.release()
+ self._req = None
def get_value(self, line: int | str) -> Value:
"""
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-07 12:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 15:46 [libgpiod][PATCH v2] bindings: python: allow releasing a LineRequest multiple times Vincent Fazio
2026-04-07 12:53 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox