Skip to content

run_process ignores thread context and spawns from threadpool #3360

@tik-stbuehler

Description

@tik-stbuehler

Hi,

run_process uses trio.to_thread.run_sync to spawn the subprocess; this means that the spawned process will inherit various context from a different thread. In my case this means it spawns in the wrong (network) namespace (see setns(2) - "reassociate thread with a namespace").

This might affect other things as well (pthreads(7) lists (among other things) capabilities and CPU affinity).

  1. the docs should mention this behavior
  2. it would be nice to have a flag to "spawn from current thread"

I'm also open to good suggestions how to work around this problem :)
(I might try prefixing the target command with ["/usr/bin/nsenter", "--target", threading.get_native_id(), "-n", "--"], or copy the trio run_process/open_process functions).

cheers,
Stefan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions