* [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait
@ 2023-05-23 13:34 Bartosz Golaszewski
2023-05-23 13:35 ` Bartosz Golaszewski
2023-05-24 7:00 ` Alexander Stein
0 siblings, 2 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-05-23 13:34 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Nicolas Frattaroli
Cc: linux-gpio, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The docs don't mention it but currently passing None as the timeout to
one of the event wait methods works like passing 0 to select() - the wait
method returns immediately. Change it to a more standard behavior - None
makes the method block indefinitely until an even becomes available for
reading.
This is a slight change in the behavior but let's hope nobody complains
as libgpiod v2 is still pretty recent and its adoption is (hopegully)
not wide-spread yet.
Suggested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
bindings/python/gpiod/chip.py | 3 ++-
bindings/python/gpiod/internal.py | 3 ---
bindings/python/gpiod/line_request.py | 3 ++-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
index 97ff340..52d0757 100644
--- a/bindings/python/gpiod/chip.py
+++ b/bindings/python/gpiod/chip.py
@@ -195,7 +195,8 @@ class Chip:
Args:
timeout:
Wait time limit represented as either a datetime.timedelta object
- or the number of seconds stored in a float.
+ or the number of seconds stored in a float. If set to 0, the
+ method returns immediately, if set to None it blocks indefinitely.
Returns:
True if an info event is ready to be read from the chip, False if the
diff --git a/bindings/python/gpiod/internal.py b/bindings/python/gpiod/internal.py
index 37e8b62..7b4598c 100644
--- a/bindings/python/gpiod/internal.py
+++ b/bindings/python/gpiod/internal.py
@@ -7,9 +7,6 @@ from typing import Optional, Union
def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool:
- if timeout is None:
- timeout = 0.0
-
if isinstance(timeout, timedelta):
sec = timeout.total_seconds()
else:
diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index a0f97b7..090467c 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -178,7 +178,8 @@ class LineRequest:
Args:
timeout:
Wait time limit expressed as either a datetime.timedelta object
- or the number of seconds stored in a float.
+ or the number of seconds stored in a float. If set to 0, the
+ method returns immediately, if set to None it blocks indefinitely.
Returns:
True if events are ready to be read. False on timeout.
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait
2023-05-23 13:34 [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait Bartosz Golaszewski
@ 2023-05-23 13:35 ` Bartosz Golaszewski
2023-05-23 13:42 ` Kent Gibson
2023-05-24 7:00 ` Alexander Stein
1 sibling, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-05-23 13:35 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Nicolas Frattaroli
Cc: linux-gpio, Bartosz Golaszewski
On Tue, May 23, 2023 at 3:34 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> The docs don't mention it but currently passing None as the timeout to
> one of the event wait methods works like passing 0 to select() - the wait
> method returns immediately. Change it to a more standard behavior - None
> makes the method block indefinitely until an even becomes available for
> reading.
>
> This is a slight change in the behavior but let's hope nobody complains
> as libgpiod v2 is still pretty recent and its adoption is (hopegully)
> not wide-spread yet.
>
> Suggested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
Cr*p, it was supposed to be Kent who suggested it and Nicolas who
Reported it. I can change it when applying if the patch is fine.
Bart
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> bindings/python/gpiod/chip.py | 3 ++-
> bindings/python/gpiod/internal.py | 3 ---
> bindings/python/gpiod/line_request.py | 3 ++-
> 3 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
> index 97ff340..52d0757 100644
> --- a/bindings/python/gpiod/chip.py
> +++ b/bindings/python/gpiod/chip.py
> @@ -195,7 +195,8 @@ class Chip:
> Args:
> timeout:
> Wait time limit represented as either a datetime.timedelta object
> - or the number of seconds stored in a float.
> + or the number of seconds stored in a float. If set to 0, the
> + method returns immediately, if set to None it blocks indefinitely.
>
> Returns:
> True if an info event is ready to be read from the chip, False if the
> diff --git a/bindings/python/gpiod/internal.py b/bindings/python/gpiod/internal.py
> index 37e8b62..7b4598c 100644
> --- a/bindings/python/gpiod/internal.py
> +++ b/bindings/python/gpiod/internal.py
> @@ -7,9 +7,6 @@ from typing import Optional, Union
>
>
> def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool:
> - if timeout is None:
> - timeout = 0.0
> -
> if isinstance(timeout, timedelta):
> sec = timeout.total_seconds()
> else:
> diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
> index a0f97b7..090467c 100644
> --- a/bindings/python/gpiod/line_request.py
> +++ b/bindings/python/gpiod/line_request.py
> @@ -178,7 +178,8 @@ class LineRequest:
> Args:
> timeout:
> Wait time limit expressed as either a datetime.timedelta object
> - or the number of seconds stored in a float.
> + or the number of seconds stored in a float. If set to 0, the
> + method returns immediately, if set to None it blocks indefinitely.
>
> Returns:
> True if events are ready to be read. False on timeout.
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait
2023-05-23 13:35 ` Bartosz Golaszewski
@ 2023-05-23 13:42 ` Kent Gibson
0 siblings, 0 replies; 5+ messages in thread
From: Kent Gibson @ 2023-05-23 13:42 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, Andy Shevchenko, Viresh Kumar, Nicolas Frattaroli,
linux-gpio, Bartosz Golaszewski
On Tue, May 23, 2023 at 03:35:30PM +0200, Bartosz Golaszewski wrote:
> On Tue, May 23, 2023 at 3:34 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > The docs don't mention it but currently passing None as the timeout to
> > one of the event wait methods works like passing 0 to select() - the wait
> > method returns immediately. Change it to a more standard behavior - None
> > makes the method block indefinitely until an even becomes available for
> > reading.
> >
> > This is a slight change in the behavior but let's hope nobody complains
> > as libgpiod v2 is still pretty recent and its adoption is (hopegully)
> > not wide-spread yet.
> >
> > Suggested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
>
> Cr*p, it was supposed to be Kent who suggested it and Nicolas who
> Reported it. I can change it when applying if the patch is fine.
>
> Bart
>
Man, wish I could get away with that little sleep.
Anyway, that works for me.
Reviewed-by: Kent Gibson <warthog618@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait
2023-05-23 13:34 [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait Bartosz Golaszewski
2023-05-23 13:35 ` Bartosz Golaszewski
@ 2023-05-24 7:00 ` Alexander Stein
2023-05-24 15:01 ` Bartosz Golaszewski
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Stein @ 2023-05-24 7:00 UTC (permalink / raw)
To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Nicolas Frattaroli, Bartosz Golaszewski
Cc: linux-gpio, Bartosz Golaszewski
Am Dienstag, 23. Mai 2023, 15:34:27 CEST schrieb Bartosz Golaszewski:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> The docs don't mention it but currently passing None as the timeout to
> one of the event wait methods works like passing 0 to select() - the wait
> method returns immediately. Change it to a more standard behavior - None
> makes the method block indefinitely until an even becomes available for
Small typo: 'an event becomes'
Regards,
Alexander
> reading.
>
> This is a slight change in the behavior but let's hope nobody complains
> as libgpiod v2 is still pretty recent and its adoption is (hopegully)
> not wide-spread yet.
>
> Suggested-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> bindings/python/gpiod/chip.py | 3 ++-
> bindings/python/gpiod/internal.py | 3 ---
> bindings/python/gpiod/line_request.py | 3 ++-
> 3 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
> index 97ff340..52d0757 100644
> --- a/bindings/python/gpiod/chip.py
> +++ b/bindings/python/gpiod/chip.py
> @@ -195,7 +195,8 @@ class Chip:
> Args:
> timeout:
> Wait time limit represented as either a datetime.timedelta
> object - or the number of seconds stored in a float.
> + or the number of seconds stored in a float. If set to 0, the
> + method returns immediately, if set to None it blocks
> indefinitely.
>
> Returns:
> True if an info event is ready to be read from the chip, False if
> the diff --git a/bindings/python/gpiod/internal.py
> b/bindings/python/gpiod/internal.py index 37e8b62..7b4598c 100644
> --- a/bindings/python/gpiod/internal.py
> +++ b/bindings/python/gpiod/internal.py
> @@ -7,9 +7,6 @@ from typing import Optional, Union
>
>
> def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) ->
> bool: - if timeout is None:
> - timeout = 0.0
> -
> if isinstance(timeout, timedelta):
> sec = timeout.total_seconds()
> else:
> diff --git a/bindings/python/gpiod/line_request.py
> b/bindings/python/gpiod/line_request.py index a0f97b7..090467c 100644
> --- a/bindings/python/gpiod/line_request.py
> +++ b/bindings/python/gpiod/line_request.py
> @@ -178,7 +178,8 @@ class LineRequest:
> Args:
> timeout:
> Wait time limit expressed as either a datetime.timedelta object
> - or the number of seconds stored in a float.
> + or the number of seconds stored in a float. If set to 0, the
> + method returns immediately, if set to None it blocks
> indefinitely.
>
> Returns:
> True if events are ready to be read. False on timeout.
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait
2023-05-24 7:00 ` Alexander Stein
@ 2023-05-24 15:01 ` Bartosz Golaszewski
0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2023-05-24 15:01 UTC (permalink / raw)
To: Alexander Stein
Cc: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar,
Nicolas Frattaroli, linux-gpio, Bartosz Golaszewski
On Wed, May 24, 2023 at 9:00 AM Alexander Stein
<alexander.stein@ew.tq-group.com> wrote:
>
> Am Dienstag, 23. Mai 2023, 15:34:27 CEST schrieb Bartosz Golaszewski:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > The docs don't mention it but currently passing None as the timeout to
> > one of the event wait methods works like passing 0 to select() - the wait
> > method returns immediately. Change it to a more standard behavior - None
> > makes the method block indefinitely until an even becomes available for
>
> Small typo: 'an event becomes'
Thanks, applied with that fixed.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-24 15:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23 13:34 [libgpiod][PATCH] bindings: python: change the interpretation of None in event wait Bartosz Golaszewski
2023-05-23 13:35 ` Bartosz Golaszewski
2023-05-23 13:42 ` Kent Gibson
2023-05-24 7:00 ` Alexander Stein
2023-05-24 15:01 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).