mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
Remove unnecessary try/catch
execute() will never throw, so no reason to wrap in try/catch.
This commit is contained in:
parent
bba0610ede
commit
58ce0df037
@ -176,18 +176,12 @@ class Fork implements Process, Strand {
|
||||
// @codeCoverageIgnoreStart
|
||||
\fclose($child);
|
||||
|
||||
try {
|
||||
Loop::set((new Loop\DriverFactory)->create()); // Replace loop instance inherited from parent.
|
||||
Loop::run(function () use ($parent) {
|
||||
$channel = new ChannelledSocket($parent, $parent, false);
|
||||
return $this->execute($channel);
|
||||
});
|
||||
$code = 0;
|
||||
} catch (\Throwable $exception) {
|
||||
$code = 1;
|
||||
}
|
||||
Loop::set((new Loop\DriverFactory)->create()); // Replace loop instance inherited from parent.
|
||||
Loop::run(function () use ($parent) {
|
||||
return $this->execute(new ChannelledSocket($parent, $parent));
|
||||
});
|
||||
|
||||
exit($code);
|
||||
exit(0);
|
||||
// @codeCoverageIgnoreEnd
|
||||
default: // Parent
|
||||
$this->pid = $pid;
|
||||
|
@ -82,25 +82,16 @@ class Thread extends \Thread {
|
||||
|
||||
// At this point, the thread environment has been prepared so begin using the thread.
|
||||
|
||||
try {
|
||||
Loop::run(function () {
|
||||
$channel = new ChannelledSocket($this->socket, $this->socket, false);
|
||||
|
||||
$watcher = Loop::repeat(self::KILL_CHECK_FREQUENCY, function () {
|
||||
if ($this->killed) {
|
||||
Loop::stop();
|
||||
}
|
||||
});
|
||||
|
||||
Loop::unreference($watcher);
|
||||
|
||||
return $this->execute($channel);
|
||||
Loop::run(function () {
|
||||
$watcher = Loop::repeat(self::KILL_CHECK_FREQUENCY, function () {
|
||||
if ($this->killed) {
|
||||
Loop::stop();
|
||||
}
|
||||
});
|
||||
} catch (\Throwable $exception) {
|
||||
return 1;
|
||||
}
|
||||
Loop::unreference($watcher);
|
||||
|
||||
return 0;
|
||||
return $this->execute(new ChannelledSocket($this->socket, $this->socket));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user