-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
开两个协程实例化同个类报 Class xxx not found #211
Labels
bug
Something isn't working
Comments
可以贴一个完整的直接可运行的代码么? |
我要怎么复现这个 BUG 呢... 有没有最小化的例子? |
方便加个好友? 我这边把程序发您看看 |
最小化验证方式 复制下面代码 到commands文件下覆盖HelloController.php * @SInCE 2.0 */ class HelloController extends Controller { public function actionTest() { //\Yii::$app->cache; $wr = new WaitReference(); for ($i=0; $i<5; $i++){ Coroutine::run(function () use($wr,$i): void { $result = \Yii::$app->cache; echo 'test'; //$instance = new OrdersService(); }); } $wr::wait($wr); } } @twose |
大概率是构造函数里面有IO切换造成的 |
<?php
use Swow\Coroutine;
spl_autoload_register(static function (string $class): void {
msleep(1); // coroutine context switch
require_once __DIR__ . '/a.php';
});
for ($i = 0; $i < 3; ++$i) {
Coroutine::run(static function (): void {
new A();
var_dump(Coroutine::getCurrent()->getId());
});
}
sleep(1); autoload 里有协程切换会导致这个问题 |
初步修复了,可以完美解决,等我把 CI 修完一起发个版本 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第一个类实例化不报错 正常运行 第二个类报错如图所示
操作系统 windows10 php版本8.1 php框架 Yii 版本2.0.45
The text was updated successfully, but these errors were encountered: