modify
This commit is contained in:
@@ -30,35 +30,9 @@ class CrontabProcess extends Process
|
|||||||
* @param \Swoole\Process $process
|
* @param \Swoole\Process $process
|
||||||
*/
|
*/
|
||||||
public function onHandler(\Swoole\Process $process): void
|
public function onHandler(\Swoole\Process $process): void
|
||||||
{
|
|
||||||
$this->channel = new Channel(1000);
|
|
||||||
Coroutine\go(function () {
|
|
||||||
$this->waitGroup();
|
|
||||||
});
|
|
||||||
$this->readByWorker($process);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $process
|
|
||||||
*/
|
|
||||||
private function readByWorker($process)
|
|
||||||
{
|
|
||||||
$this->channel->push($process->read());
|
|
||||||
|
|
||||||
// Coroutine::sleep(0.01);
|
|
||||||
|
|
||||||
$this->readByWorker($process);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
private function waitGroup()
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$content = $this->channel->pop();
|
$content = $process->read();
|
||||||
|
|
||||||
$_content = json_decode($content, true);
|
$_content = json_decode($content, true);
|
||||||
if (is_null($_content)) {
|
if (is_null($_content)) {
|
||||||
@@ -69,7 +43,7 @@ class CrontabProcess extends Process
|
|||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$this->application->error($exception->getMessage());
|
$this->application->error($exception->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
$this->waitGroup();
|
$this->onHandler($process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user