MagicStack / MagicStack/uvloop

Idea: changing libuv not to install a signal handler

未关闭
#582 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Cython
星标
11.9k
派生
616
PR 合并指标
30 天内没有已合并 PR

描述

Hi,

So I've been having problems with a python-uvloop process which is run from a container and spawns child processes. If those child processes spawn their own children which lose their parents (eg. via demonize()) then there's no way to reap them (as PID1 is honour-bound to do). I had been addressing this by patching libuv to do something analagous to FastChildWatcher - ie. reap all process in SIGCHLD handler. But this isn't really safe and can interfere with other libraries or modules (eg. a synchronous process start in another python module).

In the mean time, Python itself has deprecated child-watchers and is now using pidfd on Linux, and a dedicated wait() thread in all other cases.

This means that PID-1 programs can just install their own SIGCHLD handler to reap orphaned processes.

I was wondering if my proposal over on libuv/libuv#4179 might be of interest here? The idea would be to pass a special flag to libuv to tell it not to install a signal handler, and then use the python child watchers to handle reaping of libuv spawned processes.

Without this, a python process which sets up a SIGCHLD handler is going to break if switching from asyncio to uvloop (ie. the switch is no longer transparent, as of python 3.12)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 libuv/libuv#4179 中提出的更改,以及 uvloop 当前如何使用 libuv 处理子进程和信号。将该行为与 Python 的 child watchers、Linux 上的 pidfd 支持,以及其他地方使用的专用等待线程进行比较;只有确定了安全的集成设计并配备适当的测试,才算完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
linux, python
领域
backend, operating-systems
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。