uvloop runs at_fork hook when running subprocess
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- operating-systems
Research direction
Start by tracing uvloop's handling of asyncio.create_subprocess_exec and the fork path used after uvloop.install(), comparing it with the standard asyncio loop and os.register_at_fork behavior. Re-run the provided reproduction with the uptime subprocess; done means the after_in_child hook is not triggered for this subprocess launch.
Written by the indexing model from the issue text.
Description
Speaking about os.register_at_fork python docs explicitly state:
These calls are only made if control is expected to return to the Python interpreter. A typical subprocess launch will not trigger them as the child is not going to re-enter the interpreter.
The standard asyncio loop behaves this way. But uvloop doesn't. Repro:
import asyncio
import os
import uvloop
def hook():
os.write(2, b"TRIGGERED\n")
async def run():
process = await asyncio.create_subprocess_exec(
"uptime",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
start_new_session=True
)
stdout, stderr = await process.communicate()
print(f"STDOUT: {stdout.decode('utf-8').strip()}")
if __name__ == "__main__":
os.register_at_fork(after_in_child=hook)
print("asyncio")
asyncio.run(run())
print("uvloop")
uvloop.install()
asyncio.run(run())
Output:
asyncio
STDOUT: 16:56:42 up 35 days, 6:20, 1 user, load average: 5.21, 4.34, 4.27
uvloop
TRIGGERED
STDOUT: 16:56:42 up 35 days, 6:20, 1 user, load average: 5.21, 4.34, 4.27
- Dominant language
- Cython
- Stars
- 11.9k
- Forks
- 615
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MagicStack/uvloop
-
License not clear Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#759 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#741 · 2 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MagicStack/uvloop#702 · 8 comments · 9 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MagicStack/uvloop#766 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
MagicStack/uvloop#765 ·
All issues in MagicStack/uvloop
Similar issues
-
libc
Difficulty 2/5 1-2 days Newbie friendliness 76/100
llvm/llvm-project#225506 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ValveSoftware/Proton#10167 ·
-
next-devel: s390x build fails — chccwdev/vmur/zkey missing from initramfs after s390utils 2.44 split Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
coreos/fedora-coreos-tracker#2228 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
pop-os/plymouth-theme#43 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
danielmiessler/LifeOS#2223 · 2 comments ·