Skip to content

Commit 853699a

Browse files
committed
fix: Remove redundant output redirect from parent process
RAPID wires the runtime main process's stdout/stderr to the log egress at spawn, so the parent does not need to dial the telemetry FD provider socket — that socket exists for the forked workers, which continue to redirect in run_single. Addresses PR review feedback.
1 parent b9b6e2d commit 853699a

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

awslambdaric/lambda_multi_concurrent_utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ def run_single(
3636
bootstrap.run(handler, client)
3737

3838
@classmethod
39-
def _emit_worker_pool_event(cls, socket_path: str, max_concurrency: int):
40-
"""Emit worker pool DEBUG event once from the parent before forking."""
41-
if socket_path:
42-
cls._redirect_output(socket_path)
39+
def _emit_worker_pool_event(cls, max_concurrency: int):
40+
"""Emit worker pool DEBUG event once from the parent before forking.
41+
42+
No output redirection here: RAPID wires the runtime main process's
43+
stdout/stderr to the log egress at spawn. The FD provider socket is
44+
only for the forked workers, which redirect in run_single.
45+
"""
4346
log_sink = bootstrap.init_logging()
4447
logging.getLogger().debug(
4548
{
@@ -62,7 +65,7 @@ def run_concurrent(
6265
socket_path: str,
6366
max_concurrency: int,
6467
):
65-
cls._emit_worker_pool_event(socket_path, max_concurrency)
68+
cls._emit_worker_pool_event(max_concurrency)
6669

6770
processes = []
6871
for _ in range(max_concurrency):

tests/test_multi_concurrent_runner.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,19 @@ def test_run_concurrent_emits_worker_pool_event_once_before_spawning(
9494
"h", "a", False, "/sock", max_concurrency=3
9595
)
9696

97-
mock_emit.assert_called_once_with("/sock", 3)
98-
self.assertEqual(order_tracker.mock_calls[0], call.emit("/sock", 3))
97+
mock_emit.assert_called_once_with(3)
98+
self.assertEqual(order_tracker.mock_calls[0], call.emit(3))
9999

100100
@patch("awslambdaric.lambda_multi_concurrent_utils.logging")
101101
@patch("awslambdaric.lambda_multi_concurrent_utils.bootstrap")
102102
def test_emit_worker_pool_event_sets_up_parent_logging_and_emits(
103103
self, mock_bootstrap, mock_logging
104104
):
105105
with patch.object(MultiConcurrentRunner, "_redirect_output") as mock_redirect:
106-
MultiConcurrentRunner._emit_worker_pool_event("/sock", 16)
106+
MultiConcurrentRunner._emit_worker_pool_event(16)
107107

108-
mock_redirect.assert_called_once_with("/sock")
108+
# Parent never redirects: RAPID wires its stdout at spawn.
109+
mock_redirect.assert_not_called()
109110
mock_bootstrap.init_logging.assert_called_once_with()
110111
mock_logging.getLogger.return_value.debug.assert_called_once()
111112
event = mock_logging.getLogger.return_value.debug.call_args[0][0]
@@ -117,18 +118,6 @@ def test_emit_worker_pool_event_sets_up_parent_logging_and_emits(
117118
None, None, None
118119
)
119120

120-
@patch("awslambdaric.lambda_multi_concurrent_utils.logging")
121-
@patch("awslambdaric.lambda_multi_concurrent_utils.bootstrap")
122-
def test_emit_worker_pool_event_skips_redirect_when_no_socket(
123-
self, mock_bootstrap, mock_logging
124-
):
125-
with patch.object(MultiConcurrentRunner, "_redirect_output") as mock_redirect:
126-
MultiConcurrentRunner._emit_worker_pool_event(None, 4)
127-
128-
mock_redirect.assert_not_called()
129-
mock_bootstrap.init_logging.assert_called_once_with()
130-
mock_logging.getLogger.return_value.debug.assert_called_once()
131-
132121
@patch(
133122
"awslambdaric.lambda_multi_concurrent_utils.LambdaMultiConcurrentRuntimeClient"
134123
)

0 commit comments

Comments
 (0)