Skip to content

Commit

Permalink
自定义进程Event::wait()适配swoole v5.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Aug 22, 2024
1 parent 8d665fd commit cefc8c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Process/AbstractProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ function __start(Process $process)
}catch (\Throwable $throwable){
$this->onException($throwable);
}
Event::wait();
//加了 Event::wait() 在开启协程的时候,可能会crash,
//swoole v5.1.3 新版本为了防止出现这个情况,所以加了判断
//v4 v5的swoole 均有这个问题
if(!$this->config->isEnableCoroutine()){
Event::wait();
}
}

public function getArg()
Expand Down
2 changes: 1 addition & 1 deletion src/Process/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Config extends SplBean
protected $arg;
protected $redirectStdinStdout = false;
protected $pipeType = self::PIPE_TYPE_SOCK_DGRAM;
protected $enableCoroutine = false;
protected $enableCoroutine = true;
protected $maxExitWaitTime = 3;

/**
Expand Down

0 comments on commit cefc8c6

Please sign in to comment.