Exception
TimeoutException
A wait with a timeout ran out before it was satisfied.
Introduction#
Thrown in the waiting coroutine only; what it waited for is not cancelled: an awaited coroutine keeps running, and a channel keeps its values. run() throws it, too, when its frame's deadline passed (Frame::setTimeout).
Class synopsis#
class TimeoutException extends RuntimeException implements \Throwable, \Stringable, RethrowExceptionInterface {
}Examples#
phasync::run(function () {
$slow = phasync::go(fn () => phasync::sleep(1));
try {
phasync::await($slow, 0.01);
} catch (phasync\TimeoutException $e) {
echo "gave up\n";
}
phasync::cancel($slow);
});See also#
phasync::awaitWaits for a coroutine or a promise, and returns its result or throws the exception it ended with.CancelledExceptionThrown in a coroutine whose wait was cancelled: withphasync::cancel(), or with its frame (Frame::cancel(), the frame's deadline, a deadlock).