python-trio / python-trio/trio

Arbitrary kevent support

Open
#578 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

low-level
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

This is part of the long term plan to implement subprocess suport as outlined in https://github.com/python-trio/trio/issues/4#issuecomment-398967572 (see "Step 3", copied/pasted below for convenience).


On MacOS and the BSDs, there's this neat thing called "kqueue", which lets you efficiently wait on all kinds of different events in an async-event-loop-friendly way. Currently Trio just uses this to wait for file descriptors to become readable/writable, but in general kqueue is much more flexible. For example, the EVFILT_PROC event type lets you wait for a subprocess to exit.

trio/_core/_io_kqueue.py should provide the ability to wait on arbitrary event types. (Then we'll use that in our subprocess support to wait for EVFILT_PROC events.)

There's already a stub implementation of this, in the monitor_kevent method. This isn't tested or used currently though, so if we're going to start using it we'd want to make sure it actually works. (And possibly change how it works, if there's some other semantics that make it easier to use.)

Contributor guide

Open the contributing guide

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.

Research direction

Start in trio/_core/_io_kqueue.py at the monitor_kevent method and read the issue's linked subprocess plan, especially Step 3. Determine the intended semantics for waiting on arbitrary kqueue event types and add coverage for the behavior. Done means the existing stub works reliably for arbitrary events and is ready for subprocess support.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.