mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
fix php8.0 coroutine fail
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace ZM\Event\Listener;
|
namespace ZM\Event\Listener;
|
||||||
|
|
||||||
use OneBot\Driver\Coroutine\Adaptive;
|
use OneBot\Driver\Coroutine\Adaptive;
|
||||||
|
use OneBot\Driver\Coroutine\CoroutineInterface;
|
||||||
use OneBot\Driver\Process\ProcessManager;
|
use OneBot\Driver\Process\ProcessManager;
|
||||||
use OneBot\Util\Singleton;
|
use OneBot\Util\Singleton;
|
||||||
use ZM\Annotation\AnnotationHandler;
|
use ZM\Annotation\AnnotationHandler;
|
||||||
@@ -96,9 +97,13 @@ class WorkerEventListener
|
|||||||
$this->initUserPlugins();
|
$this->initUserPlugins();
|
||||||
|
|
||||||
// handle @Init annotation
|
// handle @Init annotation
|
||||||
Adaptive::getCoroutine()->create(function () {
|
if (Adaptive::getCoroutine() instanceof CoroutineInterface) {
|
||||||
|
Adaptive::getCoroutine()->create(function () {
|
||||||
|
$this->dispatchInit();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
$this->dispatchInit();
|
$this->dispatchInit();
|
||||||
});
|
}
|
||||||
// 回显 debug 日志:进程占用的内存
|
// 回显 debug 日志:进程占用的内存
|
||||||
$memory_total = memory_get_usage() / 1024 / 1024;
|
$memory_total = memory_get_usage() / 1024 / 1024;
|
||||||
logger()->debug('Worker process used ' . round($memory_total, 3) . ' MB');
|
logger()->debug('Worker process used ' . round($memory_total, 3) . ' MB');
|
||||||
|
|||||||
Reference in New Issue
Block a user