phasync
MySQLiAwaiter / await

Method

MySQLiAwaiter::await

Suspends the calling coroutine until the connection's asynchronous query has finished.

Description#

public static MySQLiAwaiter::await(
    mysqli $connection,
    ?float $timeout = null
): mysqli

The result is not taken here: reap_async_query() after this returns, as mysqli's own asynchronous API requires. What a query that fails throws is mysqli's decision, made there.

See the class docblock for what one coroutine at a time means, and for a wait that ends early.

Parameters#

$connection mysqli
The MySQLi connection whose query is awaited
$timeout ?float = null
The most seconds to wait for the query to complete; null, the default, waits for as long as it takes

Return values#

The connection that has a result to reap mysqli

Errors / Exceptions#

ExceptionWhen
LogicExceptionOutside a coroutine, or when another coroutine is awaiting this connection already
phasync\TimeoutExceptionWhen $timeout runs out, leaving the query in flight
RuntimeExceptionIf the service waiting for the query ended without it, or the connection was closed while it was waited for