[MISC][V1] Register process killing handler only in the main thread (#14380)
Signed-off-by: Cody Yu <hao.yu.cody@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import asyncio
|
|||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
import signal
|
import signal
|
||||||
|
import threading
|
||||||
import uuid
|
import uuid
|
||||||
import weakref
|
import weakref
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
@@ -260,7 +261,14 @@ class MPClient(EngineCoreClient):
|
|||||||
"down. See stack trace above for root cause issue.")
|
"down. See stack trace above for root cause issue.")
|
||||||
kill_process_tree(os.getpid())
|
kill_process_tree(os.getpid())
|
||||||
|
|
||||||
|
if threading.current_thread() == threading.main_thread():
|
||||||
signal.signal(signal.SIGUSR1, sigusr1_handler)
|
signal.signal(signal.SIGUSR1, sigusr1_handler)
|
||||||
|
else:
|
||||||
|
logger.warning("SIGUSR1 handler not installed because we are not "
|
||||||
|
"running in the main thread. In this case the "
|
||||||
|
"forked engine process may not be killed when "
|
||||||
|
"an exception is raised, and you need to handle "
|
||||||
|
"the engine process shutdown manually.")
|
||||||
|
|
||||||
# Serialization setup.
|
# Serialization setup.
|
||||||
self.encoder = MsgpackEncoder()
|
self.encoder = MsgpackEncoder()
|
||||||
|
|||||||
Reference in New Issue
Block a user