From 606a21fb2765a44b66a2eb299fd454bbe07f510d Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Tue, 9 Dec 2025 13:46:57 +0000 Subject: [PATCH] mitogen: Add first line comments to _first_stage() --- mitogen/parent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index 71641d36..e91504ce 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1415,7 +1415,6 @@ class Connection(object): # W: write side of interpreter stdin. # r: read side of core_src FD. # w: write side of core_src FD. - # C: the decompressed core source. # Final os.close(STDOUT_FILENO) to avoid --py-debug build corrupting stream with # "[1234 refs]" during exit. @@ -1437,8 +1436,12 @@ class Connection(object): os.environ['ARGV0']=sys.executable os.execl(sys.executable,sys.executable+'(mitogen:%s)'%sys.argv[2]) os.write(1,'MITO000\n'.encode()) + # Read `len(compressed preamble)` bytes sent by our Mitogen parent. + # `select()` handles non-blocking stdin (e.g. sudo + log_output). + # `C` accumulates compressed bytes. C=''.encode() while int(sys.argv[3])-len(C)and select.select([0],[],[]):C+=os.read(0,int(sys.argv[3])-len(C)) + # Raises `zlib.error` if compressed preamble is truncated or invalid C=zlib.decompress(C) f=os.fdopen(W,'wb',0) f.write(C)