mam następujące dwie funkcjeWyślij asynchroniczne żądanie, nie czekając na odpowiedź, używając chlać
public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait')->wait();
$this->logger->debug("I shouldn't wait");
}
public function doNotWait(){
sleep(10);
$this->logger->debug("You shouldn't wait");
}
co teraz muszę zobaczyć w moich dziennikach jest:
Started
I shouldn't wait
You shouldn't wait
Ale co widzę
Started
You shouldn't wait
I shouldn't wait
Próbowałem również użyć następujących sposobów:
Way # 1
public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait', ['synchronous' => false])->wait();
$this->logger->debug("I shouldn't wait");
}
Way # 2
public function myEndpoint(){
$this->logger->debug('Started');
$this->guzzle->requestAsync('post', 'http://myurl.com/doNotWait');
$queue = \GuzzleHttp\Promise\queue()->run();
$this->logger->debug("I shouldn't wait");
}
Ale wynik nie jest pożądane jeden. Dowolny pomysł? Używam Guzzle 6.x.
Dostałem odpowiedź tutaj https://github.com/guzzle/guzzle/issues/1429#issuecomment-197119452 – gmponos
Proszę odpowiedzieć na własne pytanie z czego pracował dla ciebie, jak i przyjmuję je poprawna odpowiedź, aby pomóc innym. –
lepiej użyć królika mq – bxN5