Skip signal handler registration when not on main thread (#18752)
This commit is contained in:
@@ -882,6 +882,8 @@ def _set_envs_and_config(server_args: ServerArgs):
|
|||||||
"Please reinstall the latest version with `pip install sgl-kernel --force-reinstall`",
|
"Please reinstall the latest version with `pip install sgl-kernel --force-reinstall`",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Signal handlers can only be registered from the main thread.
|
||||||
|
if threading.current_thread() is threading.main_thread():
|
||||||
if server_args.custom_sigquit_handler is None:
|
if server_args.custom_sigquit_handler is None:
|
||||||
# Register the signal handler.
|
# Register the signal handler.
|
||||||
# The child processes will send SIGQUIT to this process when any error happens
|
# The child processes will send SIGQUIT to this process when any error happens
|
||||||
@@ -901,6 +903,12 @@ def _set_envs_and_config(server_args: ServerArgs):
|
|||||||
f"Using custom SIGQUIT handler: {server_args.custom_sigquit_handler}"
|
f"Using custom SIGQUIT handler: {server_args.custom_sigquit_handler}"
|
||||||
)
|
)
|
||||||
signal.signal(signal.SIGQUIT, server_args.custom_sigquit_handler)
|
signal.signal(signal.SIGQUIT, server_args.custom_sigquit_handler)
|
||||||
|
else:
|
||||||
|
logger.warning(
|
||||||
|
"Signal handler is not added because the engine is not in the "
|
||||||
|
"main thread. This disables the SIGQUIT handler for cleaning up "
|
||||||
|
"the process tree when a child process fails."
|
||||||
|
)
|
||||||
|
|
||||||
# Set mp start method
|
# Set mp start method
|
||||||
mp.set_start_method("spawn", force=True)
|
mp.set_start_method("spawn", force=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user