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
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.
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.
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.
sys.path
for non absolute directories.PYTHONSTARTUP
, which causes the interactive interpreter to do something different...strace
can aslo be your friend