Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/sglang/srt/managers/detokenizer_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def run_detokenizer_process(
configure_logger(server_args)
parent_process = psutil.Process().parent()

manager = None
try:
manager = detokenizer_manager_class(server_args, port_args)
if server_args.tokenizer_worker_num == 1:
Expand All @@ -444,5 +445,6 @@ def run_detokenizer_process(
except Exception:
traceback = get_exception_traceback()
logger.error(f"DetokenizerManager hit an exception: {traceback}")
manager.maybe_clear_socket_mapping()
if manager is not None:
manager.maybe_clear_socket_mapping()
Comment on lines +448 to +449
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To improve robustness, it's advisable to wrap the cleanup logic in a try...except block. This ensures that parent_process.send_signal(signal.SIGQUIT) is always executed, even if manager.maybe_clear_socket_mapping() were to raise an unexpected exception. The main goal is to prevent the server from entering a half-dead state, so guaranteeing the signal is sent is critical.

Suggested change
if manager is not None:
manager.maybe_clear_socket_mapping()
if manager is not None:
try:
manager.maybe_clear_socket_mapping()
except Exception as e_cleanup:
logger.error(f"Error during detokenizer cleanup: {e_cleanup}")

parent_process.send_signal(signal.SIGQUIT)
Loading