MCPcopy Create free account
hub / github.com/FastLED/FastLED / TrackedPopen

Class TrackedPopen

ci/util/pio_process_killer.py:284–410  ·  view source on GitHub ↗

Context manager wrapper for subprocess.Popen with automatic tracking. Usage: with TrackedPopen(["pio", "run"], cwd=build_dir) as proc: stdout, stderr = proc.communicate() # Process automatically unregistered on exit Or without context manager: proc =

Source from the content-addressed store, hash-verified

282
283
284class TrackedPopen:
285 """Context manager wrapper for subprocess.Popen with automatic tracking.
286
287 Usage:
288 with TrackedPopen(["pio", "run"], cwd=build_dir) as proc:
289 stdout, stderr = proc.communicate()
290 # Process automatically unregistered on exit
291
292 Or without context manager:
293 proc = TrackedPopen(["pio", "run"], cwd=build_dir)
294 proc.wait()
295 proc.unregister() # Must call manually when not using context manager
296 """
297
298 def __init__(
299 self,
300 args: list[str] | str,
301 cwd: str | None = None,
302 env: dict[str, str] | None = None,
303 shell: bool = False,
304 stdout: int | None = None,
305 stderr: int | None = None,
306 stdin: int | None = None,
307 text: bool = False,
308 **kwargs: Any,
309 ) -> None:
310 """Create and register a tracked subprocess.
311
312 Args:
313 args: Command to execute
314 cwd: Working directory
315 env: Environment variables
316 shell: Use shell execution
317 stdout: stdout handling (e.g., subprocess.PIPE)
318 stderr: stderr handling
319 stdin: stdin handling
320 text: Text mode for I/O
321 **kwargs: Additional arguments for subprocess.Popen
322 """
323 self._proc = subprocess.Popen(
324 args,
325 cwd=cwd,
326 env=env,
327 shell=shell,
328 stdout=stdout,
329 stderr=stderr,
330 stdin=stdin,
331 text=text,
332 **kwargs,
333 )
334 register_pio_process(self._proc)
335
336 @property
337 def proc(self) -> subprocess.Popen[Any]:
338 """Get the underlying Popen instance."""
339 return self._proc
340
341 @property

Callers 2

run_pio_commandFunction · 0.90
run_pio_trackedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected