python-output-buffering-background-scripts

python-output-buffering-background-scripts is a skill for Claude Code, Codex from topprismdata/agent-nurture-framework. It costs 153 tokens per session (1,759 once invoked), scanned A, original, MIT.

A troubleshooting guide for Python output buffering: Python may hold standard output and error messages when a script runs without a terminal. As a result, redirected log files can stay empty while the process is still running.

In plain words
What is it for?
Use it when background Python scripts run through shell redirection, nohup, systemd, supervisord, or cron and their logs are empty or delayed. It also applies when Python subprocess output does not appear in real time.
Why use it?
It prevents developers from mistaking delayed logs for a stopped script or a permissions problem. It points to buffering as the cause when a background process is active but its output is not visible.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when background Python scripts run through shell redirection, nohup, systemd, supervisord, or cron and their logs are empty or delayed. It also applies when Python subprocess output does not appear in real time.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/topprismdata/agent-nurture-framework/03-bug-fix
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add topprismdata/agent-nurture-framework --skill 03-bug-fix
Clone the repo
git clone --depth 1 https://github.com/topprismdata/agent-nurture-framework

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-output-buffering-background-scripts

README.md
[![agentmods](https://agentmods.dev/badge/skills/topprismdata/agent-nurture-framework/03-bug-fix/github.svg)](https://agentmods.dev/skills/topprismdata/agent-nurture-framework/03-bug-fix)
Your own site
<a href="https://agentmods.dev/skills/topprismdata/agent-nurture-framework/03-bug-fix"><img src="https://agentmods.dev/badge/skills/topprismdata/agent-nurture-framework/03-bug-fix/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-output-buffering-background-scripts

Your own site · 80×15
<a href="https://agentmods.dev/skills/topprismdata/agent-nurture-framework/03-bug-fix"><img src="https://agentmods.dev/badge/skills/topprismdata/agent-nurture-framework/03-bug-fix.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 153 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,759 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00153 $0.01759
Opus 5.5 $0.00061 $0.00704
Sonnet 5.5 $0.00031 $0.00352
Haiku 4.5 $0.00015 $0.00176

Measured 2d ago against content hash cfdede9515c2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-output-buffering-background-scripts scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/skills/03-bug-fix-skill.md · 218 lines

How it starts

The opening of the file, as written. The whole thing — 218 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Output Buffering Trap for Background Scripts

Problem

When a Python script is run in the background with output redirected to a file, the log file may remain empty for hours even though the process is actively running and producing output. This creates a misleading situation where the process appears to be running correctly (it shows up in ps, consumes CPU and memory) but produces no visible output. Developers waste time investigating file permissions, path issues, or logging library configuration before discovering the real cause: Python's output buffering behavior.

Context / Trigger Conditions

This skill should be triggered when:

  • A log file or output file from a Python script is empty or incomplete, but the process is confirmed to be running (ps aux | grep script_name shows an active process)
  • Running a Python script with nohup python script.py > output.log 2>&1 & or similar background execution
  • Using systemd, supervisord, or cron to run Python scripts and logs are delayed
  • A Python subprocess's stdout/stderr is not appearing in the parent process's logs in real time
  • Output appears in the log file only after the process terminates or after a very long delay

The key diagnostic clue: the process is running but the log file is empty or significantly behind real time.

Solution

Root Cause

Python uses different buffering strategies depending on where stdout is connected:

  • Connected to a terminal (TTY): Line buffering. Output is flushed after every newline character. This is the normal interactive behavior.
  • Connected to a file or pipe (not a TTY): Fully buffered. Output is accumulated in a buffer (typically 4KB or 8KB) and only written when the buffer fills. For scripts that produce output infrequently (e.g., one line per minute during a long computation), the buffer may take hours to fill.

When you run python script.py > output.log 2>&1 &, stdout is connected to a file, not a terminal. Python switches to fully buffered mode, and output is delayed until the buffer fills.

Read the full file on GitHub · 218 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 218 lines · 153 tokens per session scan A cfdede9515c2

Subscribe to this mod's changes

python-output-buffering-background-scripts is a skill published in the GitHub repository topprismdata/agent-nurture-framework (3 stars, last pushed 3d ago), licensed MIT. It adds 153 tokens to every session and 1,759 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-14.