如何停止在visual studio代码中执行python脚本? [英] How to stop execution of python script in visual studio code?
问题描述
我有以下代码,我在 Visual Studio Code 中使用 右键单击 >在终端中运行 Python 文件
I have the following code which I am running from within Visual Studio Code using Right click > Run Python File in Terminal
import threading
def worker(tid):
"""This is what the thread actually executes"""
for i in range(tid * 100000):
print("I'm working on thread {} with count {}".format(tid, i))
return
def main():
threads = list()
for i in range(32):
t = threading.Thread(target=worker, args=(i,))
threads.append(t)
t.start()
if __name__ == "__main__":
main()
但是我想停止脚本的执行,所以我尝试了 Ctrl+C
但该程序仍在 Visual Studio Code 的集成终端中运行.有没有办法真正强制停止?
However I want to stop the execution of the script so I have tried with Ctrl+C
but the program is still running in the integrated terminal of Visual Studio Code. Is there a way to actually force the stop?
推荐答案
集成终端窗口的顶部应该有一个垃圾桶.单击垃圾桶将终止窗口和进程.
There should be a trashcan at the top of the integrated terminal window. Clicking the trashcan will kill the window and the processes.
您也可以尝试 ctrl-Z 或 ctrl-D.
You can also try ctrl-Z or ctrl-D.
这篇关于如何停止在visual studio代码中执行python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!