16 lines
468 B
Python
Executable File
16 lines
468 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Bound output from a disposable test process; never buffer it all in memory."""
|
|
import sys
|
|
|
|
remaining = 8 * 1024 * 1024
|
|
while True:
|
|
chunk = sys.stdin.buffer.read(min(65536, remaining + 1))
|
|
if not chunk:
|
|
break
|
|
if len(chunk) > remaining:
|
|
print("\nIsolated test output exceeded 8 MiB", file=sys.stderr)
|
|
sys.exit(125)
|
|
sys.stdout.buffer.write(chunk)
|
|
sys.stdout.buffer.flush()
|
|
remaining -= len(chunk)
|