Use custom wait
This commit is contained in:
parent
be9c822d11
commit
fd14f8c6b6
@ -200,16 +200,28 @@ trait Tools
|
|||||||
} elseif (!($promise instanceof Promise)) {
|
} elseif (!($promise instanceof Promise)) {
|
||||||
return $promise;
|
return $promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$resolved = false;
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
return wait($promise);
|
Loop::run(function () use (&$resolved, &$value, &$exception, $promise) {
|
||||||
} catch (\Throwable $e) {
|
$promise->onResolve(function ($e, $v) use (&$resolved, &$value, &$exception) {
|
||||||
if ($e->getMessage() !== 'Loop stopped without resolving the promise') {
|
Loop::stop();
|
||||||
//$this->logger->logger("AN EXCEPTION SURFACED " . $e, \danog\MadelineProto\Logger::ERROR);
|
$resolved = true;
|
||||||
throw $e;
|
$exception = $e;
|
||||||
}
|
$value = $v;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
throw new \Error("Loop exceptionally stopped without resolving the promise", 0, $throwable);
|
||||||
}
|
}
|
||||||
} while (true);
|
} while (!$resolved);
|
||||||
|
|
||||||
|
if ($exception) {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
public function all($promises)
|
public function all($promises)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user