Do not even try using parallel processing if not running in CLI

This commit is contained in:
Daniil Gentili 2018-12-26 21:53:10 +00:00
parent d0829a6f96
commit 495e543238
2 changed files with 19 additions and 18 deletions

View File

@ -10,8 +10,8 @@ if (PHP_MAJOR_VERSION === 5) {
echo "**********************************************************************$newline$newline";
echo "YOU ARE USING AN OLD AND BUGGED VERSION OF PHP, PLEASE UPDATE TO PHP 7$newline";
echo "PHP 5 USERS WILL NOT RECEIVE MADELINEPROTO UPDATES AND BUGFIXES$newline$newline";
echo "RECOMMENDED VERSION: PHP 7.3$newline";
echo "ALL PHP 7 VERSIONS (7.0, 7.1, 7.2, 7.3) ARE SUPPORTED$newline$newline";
echo "SUPPORTED VERSIONS: PHP 7.0, 7.1, 7.2, 7.3+$newline";
echo "RECOMMENDED VERSION: PHP 7.3$newline$newline";
echo "**********************************************************************$newline";
echo "**********************************************************************$newline";
unset($newline);

View File

@ -94,23 +94,24 @@ class Magic
self::$revision = 'Revision: '.self::$revision.$latest;
}
self::$can_parallel = false;
try {
$back = debug_backtrace(0);
$promise = \Amp\File\get(end($back)['file']);
do {
try {
if (wait($promise)) {
self::$can_parallel = true;
break;
if (php_sapi_name() === 'cli') {
try {
$back = debug_backtrace(0);
$promise = \Amp\File\get(end($back)['file']);
do {
try {
if (wait($promise)) {
self::$can_parallel = true;
break;
}
} catch (\Throwable $e) {
if ($e->getMessage() !== 'Loop stopped without resolving the promise') {
throw $e;
}
}
} catch (\Throwable $e) {
if ($e->getMessage() !== 'Loop stopped without resolving the promise') {
throw $e;
}
}
} while (true);
} catch (\Throwable $e) {
} while (true);
} catch (\Throwable $e) {
}
}
if (!self::$can_parallel && !defined('AMP_WORKER')) {
define('AMP_WORKER', 1);