Skip to content

Send env argument to subprocess.Popen#304

Merged
slhck merged 2 commits intoslhck:masterfrom
randompersona1:modify_env
Feb 3, 2026
Merged

Send env argument to subprocess.Popen#304
slhck merged 2 commits intoslhck:masterfrom
randompersona1:modify_env

Conversation

@randompersona1
Copy link
Contributor

Resolves #303

At first, I assumed I could just add an optional env argument everywhere, but that turned out to be incredibly convoluted, as the call stack wasn't really designed for that.

Instead, a small context manager modifies the environment inside its scope. Thread safety is guaranteed by a ContextVar.

Test case ensures the simple invocation works. Wasn't exactly sure how to integrate it into the existing test structure, since it's more of a "meta" change, not strictly related to normalizing.

Let me know if and how to update docs, changelog, etc.

Consumers can pass an environment dict to subprocess.Popen uses by using the
context manager ffmpeg_env. Thread safety is ensured by
contextvars.ContextVar.
@randompersona1 randompersona1 changed the title Send additional arguments to subprocess.Popen Send env argument to subprocess.Popen Feb 3, 2026
@slhck slhck merged commit 9d4c56c into slhck:master Feb 3, 2026
2 of 3 checks passed
@slhck
Copy link
Owner

slhck commented Feb 3, 2026

Thanks, this is released now!

@randompersona1
Copy link
Contributor Author

Awesome, thanks!

@randompersona1 randompersona1 deleted the modify_env branch February 3, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send additional arguments to subprocess.Popen

2 participants