PHP彗星usleep阻塞阿帕奇MPM


PHP comet usleep blocking apache mpm?

我有一颗彗星,我以这种方式运行一个while循环

$items = $statement->fetchAll();//statement is a PDO Statement
$iteration = 0;
while(count($items) == 0 && $iteration < 100){
    $items = $statement->fetchAll();
    usleep(10000);
    ++$iteration;
}

当彗星运行时,我可以看到所有其他HTTP请求都处于挂起状态。 甚至非数据库请求也处于挂起状态。为什么?

您需要

使用 PDO::commit 手动提交,因为请求正在事务中保留。

请参阅有关此行为的文档:

http://www.php.net/manual/de/pdo.commit.php

http://www.php.net/manual/en/pdo.transactions.php