停止 Sublime Text 执行无限循环 [英] Stop Sublime Text from executing infinite loop

查看:42
本文介绍了停止 Sublime Text 执行无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我做类似的事情时

while True:
    print('loop')

并在 sublime 中执行该代码我无法阻止它.我必须手动终止进程并重新启动 sublime.

and execute that code in sublime I am not able to stop it. I have to manually kill the process and restart sublime.

有没有一种方法可以设置某种 'max_execution_time' 或任何其他可以让我们很好地停止这种情况的解决方法?

Is there a way of setting some kind of 'max_execution_time' or any other workaround which allow us to stop this nicely?

推荐答案

您想使用 Ctrl+Break.对于您自己的信息,只需查看 Sublime Text 中的工具下,您就会看到 Cancel Build 和上述热键.它适用于无限循环.我只想说,我也遇到过同样的情况!;)

You want to use Ctrl+Break. For your own information, just go check under Tools in Sublime Text and you'll see Cancel Build and the above hotkey. It'll work just fine for infinite loops. Suffice to say, I've had the same happen! ;)

对于 Windows 用户,没有 Break 键,所以进入 Preferences>Key Bindings 并更改行

For Windows users, there is no Break key, so go into Preferences>Key Bindings and change the line

{ "keys": ["ctrl+break"], "command": "cancel_build" }

到不同的快捷方式,例如 Ctrl+Alt+B

to a different shortcut, such as Ctrl+Alt+B

这篇关于停止 Sublime Text 执行无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆