Why doesn't Python exit from a raised exception when executed with an absolute path?

后端 未结 4 1226
面向向阳花
面向向阳花 2021-01-11 22:25

SOLVED: Rebooting the machine appears to have removed the issue. I will update if the problem returns.

I\'m having an issue where Python2.6 hangs after

4条回答
  •  隐瞒了意图╮
    2021-01-11 22:55

    This exact issue has been biting me for awhile now on a RHEL 6 machine. In certain cases, Exceptions cause a hang. In fact, I was able to take your code verbatim and reproduce the symptom.

    Thanks to the abrtd answer, I determined that abrt-addon-python package was installed which puts abrt_exception_handler.py into the site-packages location, and that is called during python startup. This file overrides the sys.excepthook function which contacts the abrt daemon using sockets. See ABRT Project Doc for more information.

    I verified that adding -S to the python invocation prevents the hang. This is not a good solution, however, because the -S option prevents ALL site packages from being imported on startup.

    A better solution is to add the following in your python code:

    import sys
    sys.excepthook = sys.__excepthook__
    

    which restores the original exception hook and prevents the hang.

提交回复
热议问题