小编lor*_*ile的帖子

sys.exit(1) 不起作用,脚本以代码 0 结尾

我有以下代码:

try:
    self._collect_persons_status()
except manager.AsteriskManagerError:
    # If it is not possible to continue with the collection of initial
    # person statuses via Asterisk Manager, end the program with an
    # error code.
    logger.debug('*** exit with 1!!')
    sys.exit(1)
Run Code Online (Sandbox Code Playgroud)

该脚本通过 systemd 处理(作为带循环的守护进程运行)。

从日志中我可以看到*** exit with 1!!已打印,但脚本以代码 0 结束,而不是预期的 1:

脚本退出代码

我究竟做错了什么?

python systemd

2
推荐指数
1
解决办法
167
查看次数

标签 统计

python ×1

systemd ×1