本文整理匯總了Python中win32con.CTRL_C_EVENT屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32con.CTRL_C_EVENT屬性的具體用法?Python win32con.CTRL_C_EVENT怎麽用?Python win32con.CTRL_C_EVENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類win32con
的用法示例。
在下文中一共展示了win32con.CTRL_C_EVENT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import CTRL_C_EVENT [as 別名]
def handle(self, event):
"""Handle console control events (like Ctrl-C)."""
if event in (win32con.CTRL_C_EVENT, win32con.CTRL_LOGOFF_EVENT,
win32con.CTRL_BREAK_EVENT, win32con.CTRL_SHUTDOWN_EVENT,
win32con.CTRL_CLOSE_EVENT):
self.bus.log('Console event %s: shutting down bus' % event)
# Remove self immediately so repeated Ctrl-C doesn't re-call it.
try:
self.stop()
except ValueError:
pass
self.bus.exit()
# 'First to return True stops the calls'
return 1
return 0
示例2: handle
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import CTRL_C_EVENT [as 別名]
def handle(self, event):
"""Handle console control events (like Ctrl-C)."""
if event in (win32con.CTRL_C_EVENT, win32con.CTRL_LOGOFF_EVENT,
win32con.CTRL_BREAK_EVENT, win32con.CTRL_SHUTDOWN_EVENT,
win32con.CTRL_CLOSE_EVENT):
self.bus.log('Console event %s: shutting down bus' % event)
# Remove self immediately so repeated Ctrl-C doesn't re-call it.
try:
self.stop()
except ValueError:
pass
self.bus.exit()
# 'First to return True stops the calls'
return 1
return 0
示例3: _DebugCtrlHandler
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import CTRL_C_EVENT [as 別名]
def _DebugCtrlHandler(evt):
if evt in (win32con.CTRL_C_EVENT, win32con.CTRL_BREAK_EVENT):
assert g_debugService
print "Stopping debug service."
g_debugService.SvcStop()
return True
return False
示例4: __close_internal_windows
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import CTRL_C_EVENT [as 別名]
def __close_internal_windows(self):
self.log.debug("Sending CTRL_C_EVENT to chromium")
win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, self.cr_proc.pid)
self.cr_proc.send_signal(signal.CTRL_BREAK_EVENT)
self.cr_proc.send_signal(signal.CTRL_C_EVENT)
self.cr_proc.send_signal(1)
self.log.debug("Sent")
try:
self.check_process_ded() # Needed to flush the communcation pipes, sometimes
# I can't get this to fucking ever work,
# so just skip and go straight to termination.
# self.log.debug("Waiting for chromium to exit")
# try:
# self.cr_proc.wait(timeout=5)
# except subprocess.TimeoutExpired:
# pass
try:
self.cr_proc.terminate()
except ProcessLookupError:
self.log.debug("Process exited normally, no need to terminate.")
self.check_process_ded() # Processes may dangle until the pipes are closed.
try:
self.cr_proc.kill()
except ProcessLookupError:
self.log.debug("Process exited normally, no need to terminate.")
self.check_process_ded() # Processes may dangle until the pipes are closed.
except cr_exceptions.ChromeDiedError:
self.log.debug("ChromeDiedError while polling. Ignoring due to shutdown.")
# Considering we're /trying/ to kill chrome, it
# dying is OK.
self.log.debug("Pid: %s, Return code: %s", self.cr_proc.pid, self.cr_proc.returncode)
self.log.debug("Chromium closed!")