fix php8.0 coroutine fail

This commit is contained in:
sunxyw 2023-01-04 15:26:41 +08:00
parent ed40799fe3
commit 3596d6077d
No known key found for this signature in database
GPG Key ID: F391C42B19AFFC98

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace ZM\Event\Listener;
use OneBot\Driver\Coroutine\Adaptive;
use OneBot\Driver\Coroutine\CoroutineInterface;
use OneBot\Driver\Process\ProcessManager;
use OneBot\Util\Singleton;
use ZM\Annotation\AnnotationHandler;
@ -96,9 +97,13 @@ class WorkerEventListener
$this->initUserPlugins();
// handle @Init annotation
Adaptive::getCoroutine()->create(function () {
if (Adaptive::getCoroutine() instanceof CoroutineInterface) {
Adaptive::getCoroutine()->create(function () {
$this->dispatchInit();
});
} else {
$this->dispatchInit();
});
}
// 回显 debug 日志:进程占用的内存
$memory_total = memory_get_usage() / 1024 / 1024;
logger()->debug('Worker process used ' . round($memory_total, 3) . ' MB');