PHP Threaded Closure Error GuzzleHttp / client

时间:2017-01-30 19:25:11

标签: php multithreading class closures guzzlehttp

我使用 zts-php 进行线程工作我有关闭错误guzzle客户端不是序列化$this->client,我使用$client工作如何添加run()函数guzzlehttp client

use GuzzleHttp\Client;
use GuzzleHttp\Promise\EachPromise;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;
class check extends Thread 

{
 function __construct(string $url,int $timeout=60)
    {
        $this->client= new Client([

                'timeout' => $timeout
            ]);
          $this->timeout = $this->timeout;     
    }

    public function run() {

        $response =    $this->client->request('head', "http://www.google.com", [
                'on_stats' => function (TransferStats $stats) {
                    $this->uri = $stats->getEffectiveUri();
                    $this->transferTime = $stats->getTransferTime();
                }
    ]);

  }

}

我得到错误:

Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in 

0 个答案:

没有答案