1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-22 14:01:14 +01:00

Exit thread immediately if parent context died while starting

This commit is contained in:
Aaron Piotrowski 2017-07-20 23:36:28 -05:00
parent 2aa5692fdb
commit 1a6896b047
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -86,6 +86,10 @@ class Thread extends \Thread {
return; // Thread killed while requiring autoloader, simply exit. return; // Thread killed while requiring autoloader, simply exit.
} }
if (!\is_resource($this->socket) || \feof($this->socket)) {
return; // Parent context exited, no need to continue.
}
Loop::run(function () { Loop::run(function () {
$watcher = Loop::repeat(self::KILL_CHECK_FREQUENCY, function () { $watcher = Loop::repeat(self::KILL_CHECK_FREQUENCY, function () {
if ($this->killed) { if ($this->killed) {