Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110188 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 79745 invoked from network); 16 May 2020 19:04:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 May 2020 19:04:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 00DAE1804F2 for ; Sat, 16 May 2020 10:41:48 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 16 May 2020 10:41:48 -0700 (PDT) Received: by mail-oi1-f171.google.com with SMTP id i22so5271382oik.10 for ; Sat, 16 May 2020 10:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=8WZ3OdhWMWDbctuUCAw3bGSQdeW3kCLVLfoapdXEZuM=; b=W1BHbOmb+8tytaZcnnzJaBJ3xumHnxYlet6JkTcZ6K47AFUcCrpqqf2pZRgh9NUbU4 HSKVn2lggYwy/cMb6BBTrNZ//GYYnZMDwCw8dmTNjnM3Svr3FnaXo0o81hgn34fR96gw qEkZRnr7ACEQkf/WMBhRCwF2vfTfSdueWsuOV54yf0RMhw65t9J/nAFXkaJ6KgNX+xeU 5NQnza+EU7GizaqOxUWm4pMF+5BN0KN5WI9omlz0jG84lL14H/V4yM9Mk9nXjtr3gae3 v0cUy9+VY62loBsQ0AluVpnr1o9NsXGx1pxgAzCzKkwMZa9+UaPzn8OdwXTkbFvjk/S6 SIpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8WZ3OdhWMWDbctuUCAw3bGSQdeW3kCLVLfoapdXEZuM=; b=PCzj36z82lI/97dpxy8QnHKVI59mJSANqbklzUlvXfSOStXMl3a7xGIQAVAoANhSMy JL/DaiTZNwhwq5Mjw+lo5NJJk1VDQm/mfa3gW2Zkhxj3npLEMEpaOeIMmdw/gDwDXMJ3 cAyQ4bjoXSnLvJtCsJgQfadoXhLgaPqmRQqVDjTj2FYoEIMa4wg0DcIpXJI73ItG22vx IuCRPh6XEx0z/YKhHEbFcHxOnBD1uPQkRuNtiy5JNXH3xR89E+Uk5MjouWsBwlCtBcEX zmRyCTF2NcwKSIqBlLClaLuTUWhwWA68Bco7cU+U25tgZMLHU1WykMYr/f0AJnNiJvCO Ez8A== X-Gm-Message-State: AOAM530TrFPHGWk60Xzz3otxGuDXghtizSu2PLQcD8mMxYDdNHSey7Ie p+nqEEsNdbyY4P4w+wWOIaT47VAQr3YN4GZV5n53jGXV X-Google-Smtp-Source: ABdhPJxuQ+XLjFUnG4ph1Iyd6IQyxitl6jDUnjuAAbkGW4vXXW0+JjuAqZH3Qox+0HGr+gD+fy6Y/vprXF3SU2paOAY= X-Received: by 2002:aca:c4cf:: with SMTP id u198mr6009412oif.17.1589650904473; Sat, 16 May 2020 10:41:44 -0700 (PDT) MIME-Version: 1.0 Date: Sat, 16 May 2020 14:41:32 -0300 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000007a67ce05a5c77159" Subject: Graceful timeout From: david.proweb@gmail.com (David Rodrigues) --0000000000007a67ce05a5c77159 Content-Type: text/plain; charset="UTF-8" Hello! Currently we can use set_time_limit() to specify that our script will run by some seconds before we get "fatal error: maximum execution time of 1 second exceeded". And we can't catch it and keep running. I believe that it is interesting to create a function that is able to limit processing and stop when the time limit is recovered. $completeRun = set_time_limit_callback(function () { sleep(2); }, 1); var_dump($completeRun); Where $completeRun will be TRUE only if callback could run until it returns, and FALSE if timeout. It should be very useful when we need works with external resources, like RESTful, where timeout can occur and we need a better way to work with that. Or when we have few seconds to run a process. What do you think? Atenciosamente, David Rodrigues --0000000000007a67ce05a5c77159--