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

后端 未结 4 1227
面向向阳花
面向向阳花 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:53
    • Reboot the machine.

    Bowing to the graces of the all-powerful admin, I was able to get the machine rebooted. All is well. I'll update the question if the problem returns.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-11 22:55

    I tracked this problem down. It is trying to write to a socket that was held open by abrtd.

    Restarting abrtd 'fixed' the issue. This is why the machine reboot worked. I haven't found the root cause of the issue though.

    0 讨论(0)
  • 2021-01-11 23:03
    • please inspect sys.path for non absolute directories.
    • you can always break into it with a debugger, e.g. gdb
    • sometimes I have stuff in PYTHONSTARTUP, which causes the interactive interpreter to do something different...
    • strace can aslo be your friend
    0 讨论(0)
提交回复
热议问题