gpt4 book ai didi

PHP comet usleep 阻塞 apache mpm?

转载 作者:行者123 更新时间:2023-11-29 12:22:32 25 4
gpt4 key购买 nike

我在那里有一颗 cometd 我以这种方式运行一个 while 循环

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

当 Comet 运行时,我可以看到所有其他 HTTP 请求都处于挂起状态。即使是非数据库请求也是挂起的。为什么?

最佳答案

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

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

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

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

关于PHP comet usleep 阻塞 apache mpm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11126465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com