Skip to content

Commit 9342575

Browse files
committed
[None][fix] repair KeyboardInterrupt drain loop in iteration logging
The handler read 'message' which is unbound when the interrupt lands before the first recv_json(), raising UnboundLocalError. It also compared the decoded JSON object against b'None', a sentinel the sender never emits (LlmManager sends {'end': True}), so the drain loop could never terminate normally. Initialize the variable, guard the socket, and drain until the actual 'end' sentinel. Signed-off-by: lonexreb <reach2shubhankar@gmail.com>
1 parent d9c8974 commit 9342575

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎tensorrt_llm/bench/benchmark/utils/processes.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def run(address: str, log_path: Path, stop_event: MpEvent) -> None:
133133
"""
134134
context = None
135135
socket = None
136+
message = None
136137

137138
try:
138139
# Create a ZeroMQ context and socket for inter-process communication
@@ -156,12 +157,13 @@ def run(address: str, log_path: Path, stop_event: MpEvent) -> None:
156157
message = socket.recv_json()
157158
logger.debug(f"Iteration logging: Received end message")
158159
except KeyboardInterrupt:
159-
# Handle keyboard interrupt by continuing to receive
160-
# messages until "None" is received. LlmManager will
161-
# send "None" when it is finished.
160+
# Handle keyboard interrupt by continuing to receive messages until
161+
# the "end" sentinel is received. LlmManager sends {"end": True}
162+
# when it is finished.
162163
logger.info("Keyboard interrupt, exiting iteration logging...")
163-
while message != b"None":
164-
message = socket.recv_json()
164+
if socket is not None:
165+
while message is None or "end" not in message:
166+
message = socket.recv_json()
165167
finally:
166168
# Finalize the logging process by closing the socket and terminating
167169
# the context

0 commit comments

Comments
 (0)