Skip to content

max_execution_time / set_time_limit is inconsistent across OSs and unhelpful on non-windows OSs #8567

Closed as not planned

Description

@SpencerMalone

Description

The following code:

<?php

sleep(6000);
echo("hi");

Resulted in this output:

hi

But I expected this output instead:

Maximum execution time of <x> exceeded

While this is a documented limitation, I would like to argue that this should be reimplemented to match the windows implementation where it tracks the real time of the script.

  1. Max execution time being based on PHP's CPU time is unintuitive. When you set max execution time, nobody expects it to be PHP CPU time, making this an easy to trap where you think you've set yourself up to be safe against long running requests, and instead are still exposed to this failure mode.
  2. This behavior should be OS consistent. Having it inconsistent adds to operational confusion when working with PHP.
  3. If the expectation is that the SAPI be the one to handle "real" max execution time, then one of the oldest simplest SAPIs (apache's mod_php) does not have a way to handle this, and PHP CLI applications will be left in the dust, as they have no comparable way to manage max execution time.
  4. Max execution time being based on CPU time is not useful. If a request is running for 5+ minutes, I don't care if it's sleeping, stuck in a bad recursive loop, waiting on a bad mysql query, or stuck on a curl that won't resolve, I just need it to end and free up resources. Without this, I've seen requests that have lifespans of days or weeks because they've gotten stuck in novel places without a timeout.

PHP Version

7.4

Operating System

Not-windows

Activity

  1. SpencerMalone commented on May 16, 2022

    @SpencerMalone
    ContributorAuthor

    I wasn't 100% sure if this is a bug or a feature request, to me it feels like a documented bug, so I dropped it in that category. If it needs to be swapped, I'm totally fine with that.

  2. changed the title [-]max_execution_time / set_time_limit is inconsistent across OSes and unhelpful on non-windows OSes[/-] [+]max_execution_time / set_time_limit is inconsistent across OSs and unhelpful on non-windows OSs[/+] on May 16, 2022
  3. damianwadley commented on May 16, 2022

    @damianwadley
    Member

    I wasn't 100% sure if this is a bug or a feature request, to me it feels like a documented bug, so I dropped it in that category. If it needs to be swapped, I'm totally fine with that.

    I'd call it more of a feature request: it's not like the behaviors are random decisions but conscious thought was put into how it works, and changing that will (probably) require some amount of effort and planning. It would also be a significant change that should therefore wait until PHP 9.0.

  4. cmb69 commented on May 17, 2022

    @cmb69
    Member

    See #6504.

  5. github-actions commented on Aug 16, 2022

    @github-actions

    There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests.

  6. SpencerMalone commented on Aug 16, 2022

    @SpencerMalone
    ContributorAuthor

    That PR/RFC 110% solves my needs. I also poked around with a simple homebrewed extension that also utilizes itimers with success. I also appreciate the context from #6504 (comment) showing that the design considerations that originally drove this are no longer applicable. For those that want it, the RFC is also visible @ https://wiki.php.net/rfc/max_execution_wall_time

  7. cmb69 commented on Aug 16, 2022

    @cmb69
    Member

    @kocsismate, are you planning to pursue https://wiki.php.net/rfc/max_execution_wall_time sometime? :)

  8. kocsismate commented on Aug 16, 2022

    @kocsismate
    Member

    Are you planning to pursue https://wiki.php.net/rfc/max_execution_wall_time sometime? :)

    Yes, definitely! I hope that we'll have time to settle on a solution for PHP 8.3 :)

  9. github-actions commented on Nov 15, 2022

    @github-actions

    There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions