我正在运行一个计时器,在我的棘轮湿应用程序上使用react\ using循环。我希望它每小时运行3600秒,但出于某种原因,如果我将间隔设置为2147秒以上,则会得到以下警告:
Warning: stream_select(): The microseconds parameter must be greater than 0 in C
:\wamp\www\vendor\react\event-loop\StreamSelectLoop.php on line 2552147秒有什么特别的?我能做些什么来绕过这些违禁品?
事件处理程序
class Pusher implements WampServerInterface, MessageComponentInterface {
private $loop;
}
public function __construct(LoopInterface $loop) {
$this->loop = $loop;
$this->loop->addPeriodicTimer(2147, function() {
//code
});
}
public function onSubscribe(ConnectionInterface $conn, $topic) {}
public function onUnSubscribe(ConnectionInterface $conn, $topic) {}
public function onOpen(ConnectionInterface $conn) {}
public function onClose(ConnectionInterface $conn) {}
public function onCall(ConnectionInterface $conn, $id, $topic, array $params) {}
public function onPublish(ConnectionInterface $conn, $topic, $event {}
public function onError(ConnectionInterface $conn, \Exception $e) {}服务器
$loop = Factory::create();
$webSock = new Server($loop);
$webSock->listen(8080, '0.0.0.0');
new IoServer(
new HttpServer(
new WsServer(
new SessionProvider(
new WampServer(
new Pusher($loop)),
$sesshandler
)
)
),
$webSock
);
$loop->run();发布于 2015-02-05 05:06:17
这是因为PHP整数在32位平台上的限制.
2147 (秒)* 1000000 (微秒)32位平台上的~= PHP_INT_MAX .在64位平台上,限制将是30万年。
奇怪的是,React的React\EventLoop\StreamSelectLoop只使用微秒参数调用stream_select(),同时也接受秒。也许他们应该解决这个问题。作为一种解决方法,您可以重写StreamSelectLoop实现,以便在stream_select()中使用$tv_sec参数。
我创建了一个拉请求,让我们看看它是否会被接受
https://stackoverflow.com/questions/25029559
复制相似问题