Re: int|float for sleep? sleep(0.1) => sleep 0.1 seconds

From: Date: Fri, 16 Feb 2024 17:16:43 +0000
Subject: Re: int|float for sleep? sleep(0.1) => sleep 0.1 seconds
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-122398@lists.php.net to get a copy of this message
On Fri, 16 Feb 2024 at 09:36, Alexandru Pătrănescu <drealecs@gmail.com> wrote: > > > On Fri, Feb 16, 2024 at 10:18 AM Hans Henrik Bergan <hans@loltek.net> wrote: >> >> Can we make sleep accept int|float? >> Made a PR: https://github.com/php/php-src/pull/13401 >> >> For years when I wanted to sleep for 0.1 seconds, it annoyed me that I couldn't do >> sleep(0.1); >> instead I had to do >> usleep(figure out how many microseconds there are in 0.1 seconds and put it >> here); >> > > Based on previous discussions > https://externals.io/message/111448 > it seems the desired way was for a RFC to be created for this change, as it involves some small > changes that break BC. > > There is also the PR done by Michael Voříšek from 3.5 years ago where some technical > discussions took place: > https://github.com/php/php-src/pull/5961 > > Regards, > Alex > Interesting indeed. I implemented some improvements from that PR now (higher precision sleep and fixing the windows 192-issue), and got Michael Voříšek's attention :) also applied for RFC Karma. On Fri, 16 Feb 2024 at 14:20, Claude Pache <claude.pache@gmail.com> wrote: > > Hi, > > > FWIW Python's time.sleep also works like this: > https://docs.python.org/3/library/time.html#time.sleep > > > Python also implements the following: > > If the sleep is interrupted by a signal and no exception is raised by the signal handler, the > sleep is restarted with a recomputed timeout. > > > I think we should also implement that. As a consequence, > sleep(...) will always return 0. > > If we “fix” sleep(), let’s “fix” it completely. > > —Claude it seems we already have a function for that, it's called time_sleep_until(), quoting the documentation > Note: All signals will be delivered after the script wakes up. in contrast to normal sleep() that is signal interruptible. Sorry, I'm not interested in making sleep() uninterruptible, at least not until after I get int|float accepted upstream.

« previous php.internals (#122398) next »