mirror of
https://github.com/amphp/parallel.git
synced 2025-02-22 05:42:36 +01:00
Exit if constructing channel fails.
This commit is contained in:
parent
a1e62d6b20
commit
3f7f21875d
@ -85,10 +85,6 @@ 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) {
|
||||||
@ -97,7 +93,13 @@ class Thread extends \Thread {
|
|||||||
});
|
});
|
||||||
Loop::unreference($watcher);
|
Loop::unreference($watcher);
|
||||||
|
|
||||||
return $this->execute(new ChannelledSocket($this->socket, $this->socket));
|
try {
|
||||||
|
$channel = new ChannelledSocket($this->socket, $this->socket);
|
||||||
|
} catch (\Throwable $exception) {
|
||||||
|
return; // Parent context exited or destroyed thread, no need to continue.
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->execute($channel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user