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

Fix attribute error on win (#10209)

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