top-think / think-swoole

Swoole extend for thinkphp
Apache License 2.0
462 stars 105 forks source link

swoole_timer_after或Timer::after回调函数中使用Db会报错 #328

Closed erbings closed 1 year ago

erbings commented 1 year ago

PHP Fatal error: Uncaught InvalidArgumentException: The app object has not been initialized in /www/wwwroot/gameserver.com/vendor/topthink/think-swoole/src/Sandbox.php:135 Stack trace:

0 /www/wwwroot/gameserver.com/vendor/topthink/think-swoole/src/Sandbox.php(69): think\swoole\Sandbox->getApplication()

1 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/Container.php(73): think\swoole\Sandbox->think\swoole{closure}()

2 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/Facade.php(47): think\Container::getInstance()

3 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/Facade.php(96): think\Facade::createFacade()

4 /www/wwwroot/gameserver.com/app/webscoket/controller/Manager.php(452): think\Facade::__callStatic()

5 /www/wwwroot/gameserver.com/app/webscoket/controller/Manager.php(458): app\webscoket\controller\Manager->test()

6 /www/wwwroot/gameserver.com/app/webscoket/controller/Manager.php(416): app\webscoket\controller\Manager->handleMatchOverTime()

7 {main}

thrown in /www/wwwroot/gameserver.com/vendor/topthink/think-swoole/src/Sandbox.php on line 135 PHP Fatal error: Uncaught Swoole\Error: API must be called in the coroutine in /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php:203 Stack trace:

0 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php(203): proc_open()

1 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php(180): think\console\output\driver\Console->getSttyColumns()

2 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php(145): think\console\output\driver\Console->getTerminalDimensions()

3 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php(82): think\console\output\driver\Console->getTerminalWidth()

4 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/Output.php(167): think\console\output\driver\Console->renderException()

5 /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/exception/Handle.php(12 in /www/wwwroot/gameserver.com/vendor/topthink/framework/src/think/console/output/driver/Console.php on line 203