Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

uvloop runs at_fork hook when running subprocess

Open
#749 0 comments 0 reactions 0 assignees View on GitHub

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

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MagicStack/uvloop

All issues in MagicStack/uvloop

Similar issues

More Operating Systems issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.