Skip to content

Commit 606a21f

Browse files
committed
mitogen: Add first line comments to _first_stage()
1 parent 733f4bc commit 606a21f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mitogen/parent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,6 @@ def __repr__(self):
14151415
# W: write side of interpreter stdin.
14161416
# r: read side of core_src FD.
14171417
# w: write side of core_src FD.
1418-
# C: the decompressed core source.
14191418

14201419
# Final os.close(STDOUT_FILENO) to avoid --py-debug build corrupting stream with
14211420
# "[1234 refs]" during exit.
@@ -1437,8 +1436,12 @@ def _first_stage():
14371436
os.environ['ARGV0']=sys.executable
14381437
os.execl(sys.executable,sys.executable+'(mitogen:%s)'%sys.argv[2])
14391438
os.write(1,'MITO000\n'.encode())
1439+
# Read `len(compressed preamble)` bytes sent by our Mitogen parent.
1440+
# `select()` handles non-blocking stdin (e.g. sudo + log_output).
1441+
# `C` accumulates compressed bytes.
14401442
C=''.encode()
14411443
while int(sys.argv[3])-len(C)and select.select([0],[],[]):C+=os.read(0,int(sys.argv[3])-len(C))
1444+
# Raises `zlib.error` if compressed preamble is truncated or invalid
14421445
C=zlib.decompress(C)
14431446
f=os.fdopen(W,'wb',0)
14441447
f.write(C)

0 commit comments

Comments
 (0)