Skip to content

Commit b3151d4

Browse files
committed
WIP
1 parent 606a21f commit b3151d4

File tree

3 files changed

+33
-40
lines changed

3 files changed

+33
-40
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
include:
28-
- tox_env: py27-m_ans-ans2.10
29-
- tox_env: py27-m_ans-ans4
30-
31-
- tox_env: py36-m_ans-ans2.10
32-
- tox_env: py36-m_ans-ans4
33-
3428
- tox_env: py27-m_mtg
3529
- tox_env: py36-m_mtg
3630

@@ -86,34 +80,6 @@ jobs:
8680
fail-fast: false
8781
matrix:
8882
include:
89-
- tox_env: py311-m_ans-ans2.10
90-
python_version: '3.11'
91-
- tox_env: py311-m_ans-ans3
92-
python_version: '3.11'
93-
- tox_env: py311-m_ans-ans4
94-
python_version: '3.11'
95-
- tox_env: py311-m_ans-ans5
96-
python_version: '3.11'
97-
- tox_env: py313-m_ans-ans6
98-
python_version: '3.13'
99-
- tox_env: py313-m_ans-ans7
100-
python_version: '3.13'
101-
- tox_env: py313-m_ans-ans8
102-
python_version: '3.13'
103-
- tox_env: py314-m_ans-ans9
104-
python_version: '3.14'
105-
- tox_env: py314-m_ans-ans10
106-
python_version: '3.14'
107-
- tox_env: py314-m_ans-ans11
108-
python_version: '3.14'
109-
- tox_env: py314-m_ans-ans12
110-
python_version: '3.14'
111-
- tox_env: py314-m_ans-ans13
112-
python_version: '3.14'
113-
114-
- tox_env: py314-m_ans-ans13-s_lin
115-
python_version: '3.14'
116-
11783
- tox_env: py314-m_mtg
11884
python_version: '3.14'
11985

@@ -161,11 +127,6 @@ jobs:
161127
fail-fast: false
162128
matrix:
163129
include:
164-
- tox_env: py314-m_lcl-ans13
165-
python_version: '3.14'
166-
- tox_env: py314-m_lcl-ans13-s_lin
167-
python_version: '3.14'
168-
169130
- tox_env: py314-m_mtg
170131
python_version: '3.14'
171132

mitogen/parent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,13 @@ def _first_stage():
14391439
# Read `len(compressed preamble)` bytes sent by our Mitogen parent.
14401440
# `select()` handles non-blocking stdin (e.g. sudo + log_output).
14411441
# `C` accumulates compressed bytes.
1442+
# `c` supports detecting EOF (`<stdin>.read(...) -> b''`).
14421443
C=''.encode()
1443-
while int(sys.argv[3])-len(C)and select.select([0],[],[]):C+=os.read(0,int(sys.argv[3])-len(C))
1444+
c=1
1445+
while c and int(sys.argv[3])-len(C)and select.select([0],[],[]):
1446+
c=os.read(0,int(sys.argv[3])-len(C))
1447+
# Raises `TypeError` if non-blocking read returns `None`
1448+
C+=c
14441449
# Raises `zlib.error` if compressed preamble is truncated or invalid
14451450
C=zlib.decompress(C)
14461451
f=os.fdopen(W,'wb',0)

tests/first_stage_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,30 @@ def test_valid_syntax(self):
5050
)
5151
finally:
5252
fp.close()
53+
54+
def test_stage(self):
55+
options = mitogen.parent.Options(max_message_size=123)
56+
conn = mitogen.parent.Connection(options, self.router)
57+
conn.context = mitogen.core.Context(None, 123)
58+
59+
proc = testlib.subprocess.Popen(
60+
args=conn.get_boot_command(),
61+
stdout=testlib.subprocess.PIPE,
62+
stderr=testlib.subprocess.PIPE,
63+
stdin=testlib.subprocess.PIPE,
64+
)
65+
stdout, stderr = proc.communicate(conn.get_preamble(), timeout=10)
66+
67+
# proc is killed by SIGTERM as the broker kills itself
68+
self.assertEqual(-15, proc.returncode)
69+
expected_stdout_prefix = b("%s\n%s\n%s\n") % (
70+
mitogen.parent.BootstrapProtocol.EC0_MARKER,
71+
mitogen.parent.BootstrapProtocol.EC1_MARKER,
72+
mitogen.parent.BootstrapProtocol.EC2_MARKER,
73+
)
74+
self.assertTrue(
75+
stdout.startswith(expected_stdout_prefix),
76+
"%r not at start of %r" % (expected_stdout_prefix, stdout),
77+
)
78+
self.assertIn(b'shutting down', stdout)
79+
self.assertEqual(b(""), stderr)

0 commit comments

Comments
 (0)