提交 90d39057 编写于 作者: M Megvii Engine Team 提交者: huangxinda

feat(mge): add mge._exit

GitOrigin-RevId: e7f348a677483b6cd3a457426cc6a90b67b9f276
上级 846642a8
......@@ -95,6 +95,27 @@ atexit.register(_close)
del _set_fork_exec_path_for_timed_func
_exit_handlers = []
def _run_exit_handlers():
for handler in _exit_handlers:
handler()
_exit_handlers.clear()
atexit.register(_run_exit_handlers)
def _exit(code):
_run_exit_handlers()
sys.exit(code)
def _atexit(handler):
_exit_handlers.append(handler)
# subpackages
import megengine.autodiff
import megengine.data
......
......@@ -11,6 +11,7 @@ import multiprocessing as mp
import os
import queue
from .. import _exit
from ..core._imperative_rt.core2 import sync
from ..logger import get_logger
from .group import group_barrier, init_process_group
......@@ -53,6 +54,7 @@ def _run_wrapped(
sync()
if is_multimachine:
group_barrier()
_exit(0)
class launcher:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册