Re: [libgpiod] Python bindings don't allow to wait on events indefinitely

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 11, 2023 at 10:28:34PM +0200, Nicolas Frattaroli wrote:
> Hello,
> 
> in libgpiod 1.6.x, Line.event_wait's codepath had no path where ts
> as passed to ppoll could ever be NULL. This means waiting indefinitely
> was impossible.
> 
> I thought hey, maybe the new Python bindings in libgpiod 2.x fixed this,
> but no, it has made it worse by explicitly setting timeout to 0 seconds
> if it's None[1]. Obviously, this behaviour can't be changed now, because
> people depend on this API to return immediately now with None as the
> parameter, and changing it to wait indefinitely would no doubt break
> actual programs.
> 
> So I'm left wondering if there's a particular reason users of these
> bindings shouldn't wait on events indefinitely or if that same mistake
> was just made twice in a row.
> 
> Is there some way the API could be enhanced to support waiting for
> events indefinitely without having to slap a While True with
> an arbitrarily high timeout around every single invocation?
> 

That does sound like a bug to me, but the rest of your mail isn't worth
responding to.

A more productive approach could be to submit a patch that describes the
problem and suggests a fix, say:

 def poll_fd(fd: int, timeout: Optional[Union[timedelta, float]] = None) -> bool:
-    if timeout is None:
-        timeout = 0.0
-

and see where that goes.

Cheers,
Kent.



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux