Skip to content

Commit

Permalink
Try deferring timeout
Browse files Browse the repository at this point in the history
Relates to #112.
  • Loading branch information
kelunik committed Apr 20, 2020
1 parent 2c76f0f commit d0ade9f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Context/Internal/ProcessHub.php
Expand Up @@ -9,6 +9,7 @@
use Amp\Promise;
use Amp\TimeoutException;
use function Amp\call;
use function Amp\delay;

class ProcessHub
{
Expand Down Expand Up @@ -119,7 +120,9 @@ public function accept(int $pid): Promise
Loop::enable($this->watcher);

try {
$channel = yield Promise\timeout($this->acceptor[$pid]->promise(), self::PROCESS_START_TIMEOUT);
$promise = $this->acceptor[$pid]->promise();
yield delay(0);
$channel = yield Promise\timeout($promise, self::PROCESS_START_TIMEOUT);
} catch (TimeoutException $exception) {
$key = \array_search($pid, $this->keys, true);
\assert(\is_string($key), "Key for {$pid} not found");
Expand Down

0 comments on commit d0ade9f

Please sign in to comment.