Skip to content

Commit

Permalink
[master-stop-child-process] Child process is not stop when we call me…
Browse files Browse the repository at this point in the history
…thod `markAsTimedOut` it continue work on background

- Added call stop method in markAsTimedOut
- Added possibility modify timeout
  • Loading branch information
Alex Turchak authored and brendt committed Aug 19, 2020
1 parent 6ff286e commit c9f7c96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ public function markAsTimedOut(Runnable $process)
{
unset($this->inProgress[$process->getPid()]);

$this->notify();
$process->stop();

$process->triggerTimeout();

$this->timeouts[$process->getPid()] = $process;

$this->notify();
}

public function markAsFailed(Runnable $process)
Expand Down
4 changes: 2 additions & 2 deletions src/Process/ParallelProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function start(): self
return $this;
}

public function stop(): self
public function stop($timeout = 0): self
{
$this->process->stop(10, SIGKILL);
$this->process->stop($timeout, SIGKILL);

return $this;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Process/Runnable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public function catch(callable $callback);
*/
public function timeout(callable $callback);

public function stop();
/**
* @param int|float $timeout The timeout in seconds
*
* @return mixed
*/
public function stop($timeout = 0);

public function getOutput();

Expand Down
2 changes: 1 addition & 1 deletion src/Process/SynchronousProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function start()
}
}

public function stop()
public function stop($timeout = 0): void
{
}

Expand Down

0 comments on commit c9f7c96

Please sign in to comment.