- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在执行过程中终止该进程,但未能将其停止。
我的线程是无限循环线程,直到收到kill信号才会终止
我只能在终端上用kill命令终止
def signal_handler(*args):
print("Killed by user")
teardown()
sys.exit(0)
def install_signal():
for sig in (SIGABRT, SIGILL, SIGINT, SIGSEGV, SIGTERM):
signal(sig, signal_handler)
class Monitor(object):
...
def run(self):
"""Run the monitor thread
Add the tasks to threads list
"""
try:
threads = {
"streaming": Streaming(
self.args["rtsp_link"],
int(self.args["duration"]),
int(self.args["period"])
),
"telnet_vid": p,
"telnet_aud": c,
}
for sub_task in threads.values():
sub_task.setDaemon(True)
sub_task.start()
for sub_task in threads.values():
sub_task.join()
time.sleep(1)
logging.info("Completed Monitor Tasks")
except KeyboardInterrupt:
print("Ok ok, quitting")
sys.exit(1)
except BaseException as e:
print("Got BaseException")
traceback.print_exc(file=sys.stdout)
raise e
def main():
try:
install_signal()
monitor = Monitor('tests/test_configuration.txt')
monitor.run()
except KeyboardInterrupt:
print("Ok ok, quitting")
sys.exit(1)
join()
,主线程将不会被阻塞,将在几秒钟内终止,并且不再收到键盘中断
while len(running_threads) > 0 :
try:
print("To add join")
# Join all threads using a timeout so it doesn't block
# Filter out threads which have been joined or are None
running_threads = [t.join(1) for t in running_threads if t is not None and t.isAlive()]
except KeyboardInterrupt:
print("Ctrl+C received! Sending kill to threads!!!")
for t in running_threads:
t.kill_received = True
最佳答案
代替:
for sub_task in threads.values():
sub_task.join() # no timeout
running_threads = threads.values()
while running_threads:
for t in running_threads:
t.join(.1) # with timeout
running_threads = [t for t in running_threads if t.is_alive()]
关于multithreading - 如何通过ctrl + c停止多线程进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23074317/
我需要触发 Ctrl+R, Ctrl+A, Ctrl+Q 用户点击按钮时的事件。 我正在编写以下代码: $(document).ready(function () { $('#Button1'
我试图让用户只输入数字并将控件复制并粘贴到文本框。我可以限制用户仅输入数字,但复制、粘贴对我不起作用,请帮助我解决此问题。 这是我的脚本: $(".allow_only_numbers").keydo
如何重新映射快速上下命令? 我想将 Ctrl-U 重新映射到 Ctrl-K 并将 Ctrl-D 重新映射到 Ctrl-J? 我尝试了以下但没有成功...... nnoremap nnoremap
我尝试将一些 Eclipse 快捷方式重新绑定(bind)到 Ctrl+M、Ctrl+U、Ctrl+J 或 Ctrl+[ 失败。原来的快捷方式有效,但如果我尝试重新绑定(bind)到列表中的快捷方式,
这是来自谷歌的面试题。我无法自己解决。有人可以解释一下吗? 编写一个程序来打印击键序列,使其生成最大数量的字符“A”。您只能使用 4 个键:A、Ctrl+A、Ctrl+C 和 Ctrl+V。只允许 N
这是来自谷歌的面试题。我无法自己解决。有人可以解释一下吗? 编写一个程序来打印击键序列,使其生成最大数量的字符“A”。您只能使用 4 个键:A、Ctrl+A、Ctrl+C 和 Ctrl+V。只允许 N
我在 C# 中开发了 vsto 模板,在其中,我为 excel 表中的许多字段添加了数据验证。如果用户复制粘贴内容,这些验证规则将被覆盖并且不起作用。 我如何限制用户复制、粘贴、剪切。**有没有其他方
我还是 AngularJS 的新手,所以这里有一个我必须解决的问题: 我制作了一个自定义提交指令,仅当表单有效时才提交表单。可以这样使用: 一切正常,直到我尝试 RegisterCtrl用regis
在网上搜索了一下后,似乎我无法将 CtrlSpace 映射到任何/很多东西。今天有办法做到吗,我发现的通常是2岁的。 最佳答案 我遇到了同样的问题,简短的回答是可以,而且不仅仅是在 GUI 版本中。在
如何简单地想在文本框中输入一个值,使用“Ctrl+a”从文本框中选择完整的文本,然后使用Ctrl + c"然后使用 Selenium + C# 将其粘贴到与 "Ctrl + v"相同的框中。 最佳答案
我有一个模拟ctr+c & ctr+v的小程序(复制粘贴)使用系统 keybd_event 的事件。问题是程序运行后计算机继续运行,就好像按下 ctrl 键然后 - 如果我键入 a 它会选择整个文档,
我正在尝试将 Vim 命令映射到 ctrl+pgup和 ctrl+pgdn组合键。这些键的 vim 语法不起作用(即 和 ,或 和 )。 由于默认的 vim 语法不起作用,我猜测终端没有发送
如何让集成的 VSCode 终端不捕获 CTRL-E、CTRL-X 和 CTRL-A? 实际行为:执行键盘快捷键通常在终端之外执行的操作 预期行为: CTRL-X-E 应该在集成终端中打开 $EDIT
我有一个较旧的基于 Java swing 的独立应用程序,它使用 JFrame 和 JMenuBar,其中包含多个 Jmenu 元素(具有相应的 JMenuItem 项)。 在 Windows(7 和
我已经使用 VsVim 大约一年了。我总是能够使用默认的 ctrl+c 和 ctrl+v 快捷方式复制/粘贴文本。几天前它停止为我工作。我认为 VsVim 键盘设置必须以某种方式改变,以处理这些键而不
在OS X上,我已将“键盘修改器”设置中的Caps-Lock更改为CTRL。很棒,但是我想在 VIM 中使用CTRLCTRL(快速双击)来ESC(我的小指在抵制CTRL [)。可能的? 两秒钟后已经使
是否可以指定在 VIM 中按 CtrlLeft/CtrlRight 键后光标将停止的符号?是否有可能使它的行为像在 Windows 中一样?使用这些组合时光标跳得太远。此外,b/e 键有点帮助,但它们
Google Chrome 具有用于减小字体大小的键绑定(bind) Ctrl-- 和用于减小字体大小的键绑定(bind) Ctrl-+增加字体大小。我想阻止他们。我发现它们必然是 ,我做到了: do
当我更改页面比例(ctrl-+、ctrl--)时,会破坏页面布局。 最后一个元素正在掉落。 帮助我,我需要将布局更改为适当缩放的菜单。 页面: 截图: 最佳答案 因为这对您来说真的很重要,所以这里有一
当我按下 CTRL + + 或 CTRL + - 时,我想将字体大小保持为这是。它不应该变大或变小。如何实现? 最佳答案 似乎没有任何纯 css 解决方案。 并且没有干净的方法来获取当前的缩放级别。
我是一名优秀的程序员,十分优秀!