2.1 KiB
SteamCMD Install Logging & Buffering Fix Design
Goal
Improve live feedback during the install operation by adding step markers to SteamInstaller and fixing Python subprocess buffering so output streams immediately instead of blocking until process exit or large chunks accumulate.
Root Cause
When the user triggers an install, two things cause significant UI delays:
- Double Buffering:
l4d2webexecutesl4d2ctlvia a subprocess pipe, andl4d2ctlexecutessteamcmdvia another pipe. Python defaults to block-bufferingsys.stdoutwhen writing to a pipe. Inrun_command(both host and web versions),print(line, file=sys.stdout)usesflush=Falseby default. This causes Python to hold up to 8KB of log lines before sending them to the UI, causing massive "all at once" delays. - Missing Markers:
SteamInstallerwas not updated to use the new_emit_stephelper, so it provides no high-level contextual steps about whatsteamcmdis currently attempting (e.g. windows vs linux payloads).
Approach
1. Fix Python Subprocess Buffering
We will add flush=True to the pass-through print calls in our command runners. This forces Python to immediately push each line down the pipe to the UI.
- Modify
l4d2host/process.py:- Update
print(line, file=sys.stderr)toprint(line, file=sys.stderr, flush=True)inemit_stderr_message. - Update
print(line, file=output_stream)toprint(line, file=output_stream, flush=True)inpump.
- Update
- Modify
l4d2web/services/host_commands.py:- Apply the exact same
flush=Truefixes.
- Apply the exact same
2. Add Step Markers to SteamInstaller
We will import _emit_step into l4d2host/steam_install.py and emit progress markers before executing the respective SteamCMD downloads.
- Before the linux download:
Step: downloading linux platform payload... - Before the windows download:
Step: downloading windows platform payload... - After the loop:
Step: installation complete.
Safety
These changes do not alter steamcmd's execution arguments or paths. The flush=True change only affects how quickly Python pushes strings through standard standard IO pipes, strictly improving SSE user experience.