[英]python shell stuck on exit
Python doesn't exit if I have imported two libraries in a certain order. 如果我按特定顺序导入了两个库,Python就不会退出。 I'm using the python libraries scitools and fenicstools .
我正在使用python库scitools和fenicstools 。
In the python shell, the following will work: 在python shell中,以下内容将起作用:
import fenicstools
import scitools
exit()
This won't exit but hang (reversed the imports): 这不会退出但挂起(反转导入):
import scitools # ok
import fenicstools # ok
exit() # gets me stuck, I can still exit with Ctrl+C
I can reproduce this on two Ubuntu 14.04 machines and am now at a complete loss. 我可以在两台Ubuntu 14.04机器上重现这一点,现在我完全失去了。 How do I even start debugging such an issue?
我怎么开始调试这样的问题?
Background: I'm using sumatra to keep track of my numerical simulations. 背景:我正在使用苏门答腊来跟踪我的数值模拟。 It gathers and logs the versions of the dependencies of my project.
它收集并记录我的项目的依赖项的版本。 I thus have no control over the order in which it tries to do so.
因此,我无法控制它试图这样做的顺序。 Result: It gets stuck.
结果:卡住了。
Edit: Following @ErlVolton's suggestion, I tried pdb. 编辑:按照@ ErlVolton的建议,我尝试了pdb。 Put the two imports in their problematic order in a file called
test.py
. 将两个导入的问题顺序放在名为
test.py
的文件中。
$ pdb test.py
> /home/gallomania/test.py(1)<module>()
-> import scitools
(Pdb) n
> /home/gallomania/test.py(2)<module>()
-> import fenicstools
(Pdb) n
--Return--
> /home/gallomania/test.py(2)<module>()->None
-> import fenicstools
(Pdb) exit
... This makes pdb not exit. ...这使pdb无法退出。
Use pdb to step through each operation and see which line of code fenicstools is hanging on in its __init__.py
使用pdb逐步执行每个操作,看看它的
__init__.py
挂着哪行代码fenicstools
https://docs.python.org/2/library/pdb.html https://docs.python.org/2/library/pdb.html
Example: 例:
$ pdb test.py
> /home/cleekley/test/test.py(1)<module>()
-> import sys
(Pdb) s
> /home/cleekley/test/test.py(2)<module>()
-> import time
(Pdb) s
> /home/cleekley/test/test.py(4)<module>()
-> while True:
(Pdb) s
> /home/cleekley/test/test.py(5)<module>()
-> time.sleep(1)
(Pdb) s
> /home/cleekley/test/test.py(4)<module>()
-> while True:
(Pdb) quit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.