Skip to content

Instantly share code, notes, and snippets.

@qix
Created March 31, 2015 17:53
Show Gist options
  • Save qix/f0e3ecb18e4183978850 to your computer and use it in GitHub Desktop.
Save qix/f0e3ecb18e4183978850 to your computer and use it in GitHub Desktop.
<?hh
function printResult($result) {
var_dump($result->vectorRowsTyped());
}
async function genMain() {
$conn = await AsyncMysqlClient::connect(
'127.0.0.1',
3306,
'authbox',
'root',
'',
);
$queries = [];
for ($i = 0; $i < 1000; $i++) {
$queries[] = "SELECT 1";
}
// Yay instant:
$results = await $conn->multiQuery($queries);
array_map(printResult, $results);
$a = $conn->query($queries[0]);
sleep(0.01);
// Throws "Fatal error: Uncaught exception 'InvalidArgumentException' with message 'attempt to invoke method on a busy connection'"
$b = $conn->query($queries[1]);
$result = await $a;
printResult($result);
$result = await $b;
printResult($result);
}
genMain()->join();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment