您如何在Jython中拦截键盘中断(CTRL-C)? [英] How do you intercept a keyboard interrupt (CTRL-C) in Jython?
本文介绍了您如何在Jython中拦截键盘中断(CTRL-C)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我尝试过的...
This is what I've tried...
from sun.misc import Signal
from sun.misc import SignalHandler
class InterruptHandler(SignalHandler):
def handle(self):
print "Shutting down server..."
Signal.handle(Signal("INT"),InterruptHandler())
它基于以下 http://www.javaspecialists.co.za/archive/Issue043.html ,但显然我缺少了一些东西.
It's based on this http://www.javaspecialists.co.za/archive/Issue043.html, but evidently I'm missing something.
推荐答案
看起来像Jython中的错误 .有一些解决方法.
Looks like a bug in Jython. There are some workarounds given there.
这篇关于您如何在Jython中拦截键盘中断(CTRL-C)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文