PHP comet usleep blocking apache mpm?

﹥>﹥吖頭↗ 提交于 2019-12-24 03:27:52

问题


I've a comet there I run an while loop in this way

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

When the comet runs I can see all other HTTP requests are pending. even non-database requests are pending. Why ?


回答1:


You need to manually commit using PDO::commit as the request are being hold in a transaction.

Please see the docs about this behavior:

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

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



来源:https://stackoverflow.com/questions/11126465/php-comet-usleep-blocking-apache-mpm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!