Download the PHP package wikimedia/request-timeout without Composer
On this page you can find all versions of the php package wikimedia/request-timeout. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wikimedia/request-timeout
More information about wikimedia/request-timeout
Files in wikimedia/request-timeout
Package request-timeout
Short Description Request timeout library for Excimer with plain PHP fallback
License MIT
Homepage https://www.mediawiki.org/wiki/RequestTimeout
Informations about the package request-timeout
Excimer is an extension for PHP which provides flexible userspace timers.
This library provides a global request timeout concept, ideally using Excimer, but with a fallback to set_time_limit() if Excimer is not available.
Typical usage:
This sets a timer for 20 seconds of wall clock time. When it expires, a TimeoutException will be thrown.
It is possible to query the amount of time remaining:
This works in the fallback mode.
The library provides a critical section concept. If a critical section is active, timeouts will be queued, rather than immediately thrown. The timeout exception will be thrown once no critical section is open.
It is important to always exit a critical section. If the code in the critical section can throw an error, try/finally can be used to ensure that the critical section is exited. Alternatively we provide a scope variable model:
The critical section exits when the scope object is destroyed. However, with
this method, it is important to not terminate the request during the critical
section, for example by calling exit()
, or by keeping the scope object in
global variable after the function returns. The library may throw an exception
from a destructor during request shutdown, which causes a PHP fatal error.
Critical sections are not functional in the fallback mode.