-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Fork in Coroutine (Swoole\Error: must be forked outside the coroutine) #2716
Comments
|
这个方法无效,测试了几种方法:
有效
|
问题没解决就关了呢? |
Sorry, 前面的回答写错了, 由于现在推全协程, 所以只能通过老的异步API或是php.ini关闭, 异步API是 |
那就是不能在运行时灵活关闭协程,这会影响部署(其他swoole 4应用就不能同时部署),能否给用户运行时关闭协程的开关呢? |
协程不能开进程,确实很难受 |
@kcloze |
那其实 Swoole 是不是就可以这样去处理?如果在协程内 fork 就改成非 Worker 进程 fork ? |
不行 不同进程上下文不一样 需要自己设计 就和SWOOLE_PROCESS的模式一样 专门有个manager进程去fork,但是一些预备工作要在start之前做好;如果是动态fork,就不是很好把控,可能一些工作做到了一半fork了,复杂的环境下,不一定能正确清理,不清理直接fork肯定会产生意料之外的问题 还有一种是使用exec,上下文无关的,安全的fork,但是不是很灵活 |
楼上写的3种办法都没有成功,老版本请用如下代码设置。 $http = new swoole_http_server('127.0.0.1', 9501); 这样应该也能够解决灵活部署或者多服务并存的问题; swoole swoole support => enabled 升级成功 php --ri swoole swoole Swoole => enabled |
swoole-jobs的多进程模块,没有用到http server |
swoole 4.4.2 默认开启了协程,不允许在协程环境下 Swoole\Process->start(),造成之前的代码不兼容,有什么好的办法?全局禁用协程也不行
swoole-jobs之前基于\Swoole\Timer::tick下调用Swoole\Process实现,代码见这里:
[Swoole\Timer::tick]](https://github.com/kcloze/swoole-jobs/blob/master/src/Process.php#L252)
[Swoole\Process](https://github.com/kcloze/swoole-jobs/blob/master/src/Process.php#L152
)
The text was updated successfully, but these errors were encountered: