gpt4 book ai didi

python - 如何中断 python 中的阻塞方法?

转载 作者:太空宇宙 更新时间:2023-11-03 15:25:45 25 4
gpt4 key购买 nike

通常我可以使用 Ctrl+C 中断一些东西,但有时当我使用线程时它不起作用 - 下面的示例。

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.sleep(100)
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
K eyboardInterrupt
>>> import Queue
>>> q = Queue.Queue(maxsize=3)
>>> q.put(0)
>>> q.put(1)
>>> q.put(2)
>>> q.put(3)
^C^C^C^C^C^C^C^C

^C^C^C

^C^C
^C
@*#()#@#@$!!!!!

编辑:有没有办法回到口译员那里?到目前为止的解决方案完全杀死了 python 和你现有的命名空间..

最佳答案

您可以使用 Ctrl+\ 终止 Python 解释器。

这将发送一个 SIGQUIT 而不是 SIGINT

关于python - 如何中断 python 中的阻塞方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7315981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com