process.try_wait
process.try_wait
功能
非阻塞检查已启动子进程是否退出。
语法
process(program).child().try_wait()
参数
无参数。
返回值
| 类型 | 说明 |
|---|---|
| Int/Empty | 已退出时返回退出码;仍在运行或没有子进程句柄返回 Empty。 |
示例
cmd = process('cmd') result = cmd.try_wait() // 输出: print result
注意事项
- try_wait 不会阻塞等待进程结束。
非阻塞检查已启动子进程是否退出。
process(program).child().try_wait()
无参数。
| 类型 | 说明 |
|---|---|
| Int/Empty | 已退出时返回退出码;仍在运行或没有子进程句柄返回 Empty。 |
cmd = process('cmd') result = cmd.try_wait() // 输出: print result