首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
实现自己的定时管理器报swoole_process::read(): have not pipe, can not use write()
使用网络上一个用swoole写的crontab定时管理脚本,启动时,发现会报“swoole_process::read(): have not pipe, can not use write()”的错误,求大神看。 ```php /** * 创建一个子进程 * @param $task */ public function create_process($id, $task) { $this->task = $task; $process = new swoole_process(array($this, "run")); if (!($pid = $process->start())) { } //记录当前任务 Crontab::$task_list[$pid] = array( "start" => microtime(true), "id" => $id, "task" => $task, "type" => "crontab", "process" =>$process, ); swoole_event_add($process->pipe, function ($pipe) use ($process) { $task = $process->read(); list($pid, $sec) = explode(",", $task); if (isset(Crontab::$task_list[$pid])) { $tasklist = Crontab::$task_list[$pid]; Crontab::$delay[$pid] = array("start"=>time() + $sec,"task"=>$tasklist["task"]); $process->write($task); } }); } ```
发布于9年前 · 0 次浏览 · 来自
提问
小
小蜜蜂
使用网络上一个用swoole写的crontab定时管理脚本,启动时,发现会报“swoole_process::read(): have not pipe, can not use write()”的错误,求大神看。 ```php /** * 创建一个子进程 * @param $task */ public function create_process($id, $task) { $this->task = $task; $process = new swoole_process(array($this, "run")); if (!($pid = $process->start())) { } //记录当前任务 Crontab::$task_list[$pid] = array( "start" => microtime(true), "id" => $id, "task" => $task, "type" => "crontab", "process" =>$process, ); swoole_event_add($process->pipe, function ($pipe) use ($process) { $task = $process->read(); list($pid, $sec) = explode(",", $task); if (isset(Crontab::$task_list[$pid])) { $tasklist = Crontab::$task_list[$pid]; Crontab::$delay[$pid] = array("start"=>time() + $sec,"task"=>$tasklist["task"]); $process->write($task); } }); } ```
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2017-06-22
w
wayswei
swoole-crontab这个开发组件,github地址:github.com/osgochina/swoole-crontab
赞
0
回复
2017-06-29
大
大林
github.com/fucongcong/Group 自己写的CronTab 服务,你可以参考看看。
赞
0
回复