hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

stdio_stdout_flood_entrypoint.mojo (609B)


      1 """Test-only stdio entrypoint that floods stdout before reading stdin.
      2 
      3 Exercises LC04: the parent must drain stdout concurrently with writing a large
      4 request instead of deadlocking on a full stdout pipe. The flood is whitespace,
      5 which JSON parsing tolerates, so a correctly interleaved run succeeds.
      6 """
      7 
      8 from std.io.io import _fdopen
      9 from std.sys import stdin
     10 
     11 
     12 def main() raises:
     13     var spaces = String("")
     14     for _ in range(1000):
     15         spaces += " "
     16     for _ in range(100):
     17         print(spaces)
     18     with _fdopen["r"](stdin) as input_file:
     19         _ = input_file.readline()
     20     print('{"ok":true}')