Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122398 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id CD5D61ADA70 for ; Fri, 16 Feb 2024 19:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708103822; bh=466MQhCKUCIH9JjQJ02McoO8K1zZPjAt+qEu9ZdsrwU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WqMURDknP+kOlFPTYN6/ygHdUGX1lBNKaDe30RuHchB+aVHPaths2EQX7Sa6WDHSY cCbZvqg/u/QTlOiKL/6EoDXfXkZFAAsD8Pu/DBCTvj8G2yQuyP4aDvdabpNcgDZLv9 cZ/MITSPnxqOjmfQplyp5GJEnhzOpvFjrG8RE5iPaiBETwDGSiWkWhyOl7OIuUI+7X IhnQ0OvtJ0/XlewYavDuOktIZvCsBKGUiy1KbbE+aNNn9WMVDsku6xk/nfd5F+2oNW f3DIlcuPbrO5PM3aGGl/sX0ISqhpR2ranKQ2p9HdD5ZtdZ2UwiHCtoTTj5MM19yVyq s21CCazsDpLKQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 70270180EE5 for ; Fri, 16 Feb 2024 09:17:01 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_05, DKIM_INVALID,DKIM_SIGNED,DMARC_MISSING,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from dragonfly.birch.relay.mailchannels.net (dragonfly.birch.relay.mailchannels.net [23.83.209.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 16 Feb 2024 09:17:00 -0800 (PST) X-Sender-Id: dreamhost|x-authsender|hans@loltek.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 940D0C1BE1 for ; Fri, 16 Feb 2024 17:16:57 +0000 (UTC) Received: from pdx1-sub0-mail-a262.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 39EA5C197D for ; Fri, 16 Feb 2024 17:16:56 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1708103816; a=rsa-sha256; cv=none; b=c9uh1DP9SsLJw2/eIQ3N1JAKj37SxqZchr3yZ2Ypp7KbBrFVpI8DDxY8BGHr+oXZSgMmYA TA5xzkPbHQIo+NAVW9pjnDmvRe9HLfjn70FQ0p4baVfBW9FG8YJzVLsOxi+7ybvbjIbdIa 87lIh6Pq5ZnTii8a0rt/cVhvHIuotSIm7EU6QNFJ2XHF5K5rqFOok1TPIAwtoLGKNjMEWN YyXwadipgWrxuGfDnGMPO6kyx0N1cSMYGoGj36e+VHNoLE87Az9wmf7RlU2PCoC0dnZ5y9 ZUxoGLao6gjdBeJohFyCy9dM12+YyP14lR3uawUIac4qtkxjtX5nolMHx2ODjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1708103816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ucnh829HOSqkwevd8ZqX9BHjHIJ4pJb2CR3PdNKLPLg=; b=qhd8cw+Z5d4C42XWlV5Bp/89dFwf9O7p93FePRy+D/kMUjaHY9UQZhqtNB5hJPXVZZaRPU FLWz9n1Bi8I3coSIjG7mNUyfCTHfuO+jhoXHqWGGVW6wm1nke/iRl6+XARHUAUaPIPbng7 3Kr8PgBQvDwTNEnEWPF4UcWGFHYa1PmXvJjKed2hXBucJTeudf9HR45kYwDCXob6/Q4q0m V1aGR3BRmDdmARp7N6JA0IuXd5PYkXH1zWeIJ4Nzlv4iXkqzVhDvhOTsH7xbB0UQ8B0GGt /6B9+ykcU+FZaUG6l8aRYxJczbvvF+j6mkrMker+p4SWWSu+/GGCMkrzsAeUhQ== ARC-Authentication-Results: i=1; rspamd-6bdc45795d-hpcxz; auth=pass smtp.auth=dreamhost smtp.mailfrom=hans@loltek.net X-Sender-Id: dreamhost|x-authsender|hans@loltek.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|hans@loltek.net X-MailChannels-Auth-Id: dreamhost X-Hysterical-Whimsical: 16cc8eb960462f83_1708103816451_773217971 X-MC-Loop-Signature: 1708103816451:160019373 X-MC-Ingress-Time: 1708103816451 Received: from pdx1-sub0-mail-a262.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.127.49.120 (trex/6.9.2); Fri, 16 Feb 2024 17:16:56 +0000 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hans@loltek.net) by pdx1-sub0-mail-a262.dreamhost.com (Postfix) with ESMTPSA id 4TbzBJ0Vjcz4g for ; Fri, 16 Feb 2024 09:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=loltek.net; s=dreamhost; t=1708103816; bh=ucnh829HOSqkwevd8ZqX9BHjHIJ4pJb2CR3PdNKLPLg=; h=From:Date:Subject:To:Cc:Content-Type:Content-Transfer-Encoding; b=Wr8ZxlH8JwvVxZ8dJAvapV96Wz1NOutCr6QCZpzyClvKIVMghkGANq3pFrlEo8CgF GhN9gcsoGvwsXjlJ5mQDMCQw5NPmvRPm73RBHfziFiAD+s00CrFnaYoNPIWi+edP5v TZi6dy2bvt5kfqsiiueMy0/3rFK6WEuSLbkNg4++0c/phzoM7HcKBhuNQhHGYh6OPp cc9D2+U8QeH8bs9G/YmM9v35CXWU5JNexJn0t/H6xpCHmkp6BzvgUkLYyxA5CZw8wR jCRK/3X4/y+pHgBzXZuAEFOGHzIWzzo4NpR5uX5yG2kMO2X/1UfDjLr7tyzfBMNX/6 TnoTPzR9xGPdw== Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-dbed0710c74so882132276.1 for ; Fri, 16 Feb 2024 09:16:56 -0800 (PST) X-Gm-Message-State: AOJu0YzkGSKyZeP/f2ZnbC9dMGdp7GW2rr+61F+KcWe7cSXqtT1cAEh/ 136j8uMQFNtY3D0j1s/Q7lVb000nOCskNxeLVdwiWxnCgfjjlXHBBPbPGtg2P5ki84uWol+ynam VpY0Nl9QANALe++aUhBrPiJdo1As= X-Google-Smtp-Source: AGHT+IE0FgpxOBVxdiKCTR3X/htjsuDJ5qi+laJrUWDKSS5je4QqLmt4+7//MbaNZ01lodNjyW9kisC/RkA3J8kEV+0= X-Received: by 2002:a25:2983:0:b0:dc7:46b7:b7f6 with SMTP id p125-20020a252983000000b00dc746b7b7f6mr5267478ybp.28.1708103815402; Fri, 16 Feb 2024 09:16:55 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 16 Feb 2024 18:16:43 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PHP-DEV] int|float for sleep? sleep(0.1) => sleep 0.1 seconds To: Claude Pache Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: hans@loltek.net (Hans Henrik Bergan) On Fri, 16 Feb 2024 at 09:36, Alexandru P=C4=83tr=C4=83nescu wrote: > > > On Fri, Feb 16, 2024 at 10:18=E2=80=AFAM Hans Henrik Bergan 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 c= ouldn't do >> `sleep(0.1);` >> instead I had to do >> `usleep(figure out how many microseconds there are in 0.1 seconds and pu= t 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=C5=99=C3=AD=C5=A1ek from 3.5 year= s 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=C5=99=C3=AD=C5=A1ek's attention :) also applied for RFC Karma. On Fri, 16 Feb 2024 at 14:20, Claude Pache 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(...)` wil= l always return `0`. > > If we =E2=80=9Cfix=E2=80=9D sleep(), let=E2=80=99s =E2=80=9Cfix=E2=80=9D = it completely. > > =E2=80=94Claude 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.