未验证 提交 82c6434d 编写于 作者: L Lin Manhui 提交者: GitHub

Fix attribute error on win (#10209)

上级 45848fda
......@@ -53,17 +53,23 @@ def term_mp(sig_num, frame):
def set_signal_handlers():
pid = os.getpid()
pgid = os.getpgid(os.getpid())
# XXX: `term_mp` kills all processes in the process group, which in
# some cases includes the parent process of current process and may
# cause unexpected results. To solve this problem, we set signal
# handlers only when current process is the group leader. In the
# future, it would be better to consider killing only descendants of
# the current process.
if pid == pgid:
# support exit using ctrl+c
signal.signal(signal.SIGINT, term_mp)
signal.signal(signal.SIGTERM, term_mp)
try:
pgid = os.getpgid(pid)
except AttributeError:
# In case `os.getpgid` is not available, no signal handler will be set,
# because we cannot do safe cleanup.
pass
else:
# XXX: `term_mp` kills all processes in the process group, which in
# some cases includes the parent process of current process and may
# cause unexpected results. To solve this problem, we set signal
# handlers only when current process is the group leader. In the
# future, it would be better to consider killing only descendants of
# the current process.
if pid == pgid:
# support exit using ctrl+c
signal.signal(signal.SIGINT, term_mp)
signal.signal(signal.SIGTERM, term_mp)
def build_dataloader(config, mode, device, logger, seed=None):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册