def signal_quit(self, signum, frame): log.info("") log.info("proxy process pid %s got signal %s, exiting", os.getpid(), SIGNAMES.get(signum, signum)) self.exit = True signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.stop(SIGNAMES.get(signum, signum))
def signal_quit(self, signum, _frame=None): log.info("") log.info("proxy process pid %s got signal %s, exiting", os.getpid(), SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.stop(None, SIGNAMES.get(signum, signum)) #from now on, we can't rely on the main loop: register_SIGUSR_signals()
def signal_quit(self, signum, _frame=None): log.info("") log.info("proxy process pid %s got signal %s, exiting", os.getpid(), SIGNAMES.get(signum, signum)) QueueScheduler.stop(self) self.message_queue.put(None, False) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.stop(None, SIGNAMES.get(signum, signum))
def handle_app_signal(self, signum, _frame=None): sys.stderr.write("\ngot signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() signal.signal(signal.SIGINT, self.handle_deadly_signal) signal.signal(signal.SIGTERM, self.handle_deadly_signal) self.signal_cleanup() self.timeout_add(0, self.signal_disconnect_and_quit, 128 + signum, "exit on signal %s" % SIGNAMES.get(signum, signum))
def app_signal(signum, frame): sys.stderr.write("\ngot signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.timeout_add( 0, self.disconnect_and_quit, 128 + signum, "exit on signal %s" % SIGNAMES.get(signum, signum))
def app_signal(signum, frame): sys.stderr.write("\ngot signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.signal_cleanup() self.timeout_add(0, self.signal_disconnect_and_quit, 128 + signum, "exit on signal %s" % SIGNAMES.get(signum, signum))
def show_signal(): app.show() app.client.cleanup() glib.timeout_add( 1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True)
def signal_quit(self, signum, frame): log.info("") log.info("got signal %s, exiting", SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.idle_add(self.clean_quit, True) self.idle_add(sys.exit, 128 + signum)
def signal_quit(self, signum, frame): log.info("") log.info("got signal %s, exiting", SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.idle_add(self.clean_quit) self.idle_add(sys.exit, 128 + signum)
def deadly_signal(sig, frame): log.warn("got deadly signal %s", SIGNAMES.get(sig, sig)) glib.idle_add(ss.stop) glib.idle_add(glib_mainloop.quit) def force_quit(sig, frame): sys.exit() signal.signal(signal.SIGINT, force_quit) signal.signal(signal.SIGTERM, force_quit)
def os_signal(signum, _frame=None): try: sys.stderr.write("\n") sys.stderr.flush() log.info("client got signal %s", SIGNAMES.get(signum, signum)) except Exception: pass self.handle_app_signal(signum)
def signal_quit(self, signum, frame): sys.stdout.write("\n") sys.stdout.flush() self._closing = True log.info("got signal %s, exiting", SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.idle_add(self.clean_quit) self.idle_add(sys.exit, 128 + signum)
def handle_signal(signum): app.show() client = app.client if client: client.cleanup() else: Gtk.main_quit() GLib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) GLib.timeout_add(1000, app.set_info_color, True)
def signal_quit(self, signum, frame): sys.stdout.write("\n") sys.stdout.flush() self._closing = True log.info("got signal %s, exiting", SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.idle_add(self.clean_quit) self.idle_add(sys.exit, 128+signum)
def handle_signal(signum): try: sys.stderr.write("\n") sys.stderr.flush() get_util_logger().info("got signal %s", SIGNAMES.get(signum, signum)) except (IOError, OSError): pass callback(signum)
def handle_app_signal(self, signum, _frame=None): try: log.info("exiting") except Exception: pass signal.signal(signal.SIGINT, self.handle_deadly_signal) signal.signal(signal.SIGTERM, self.handle_deadly_signal) self.signal_cleanup() reason = "exit on signal %s" % SIGNAMES.get(signum, signum) self.timeout_add(0, self.signal_disconnect_and_quit, 128 + signum, reason)
def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal)
def deadly_signal(signum, _frame): info("got deadly signal %s, exiting\n" % SIGNAMES.get(signum, signum)) run_cleanups() # This works fine in tests, but for some reason if I use it here, then I # get bizarre behavior where the signal handler runs, and then I get a # KeyboardException (?!?), and the KeyboardException is handled normally # and exits the program (causing the cleanup handlers to be run again): #signal.signal(signum, signal.SIG_DFL) #kill(os.getpid(), signum) os._exit(128 + signum)
def handle_signal(self, sig): """ This is for OS signals SIGINT and SIGTERM """ #next time, just stop: register_os_signals(self.signal_stop) signame = SIGNAMES.get(sig, sig) log("handle_signal(%s) calling stop from main thread", signame) self.send("signal", signame) self.timeout_add(0, self.cleanup) #give time for the network layer to send the signal message self.timeout_add(150, self.stop)
def app_signal(signum, _frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal)
def deadly_signal(signum, frame): sys.stdout.write("got deadly signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stdout.flush() run_cleanups() # This works fine in tests, but for some reason if I use it here, then I # get bizarre behavior where the signal handler runs, and then I get a # KeyboardException (?!?), and the KeyboardException is handled normally # and exits the program (causing the cleanup handlers to be run again): #signal.signal(signum, signal.SIG_DFL) #kill(os.getpid(), signum) os._exit(128 + signum)
def handle_signal(self, sig, frame): """ This is for OS signals SIGINT and SIGTERM """ #next time, just stop: signal.signal(signal.SIGINT, self.signal_stop) signal.signal(signal.SIGTERM, self.signal_stop) signame = SIGNAMES.get(sig, sig) log("handle_signal(%s, %s) calling stop from main thread", signame, frame) self.send("signal", signame) self.cleanup() #give time for the network layer to send the signal message gobject.timeout_add(150, self.stop)
def handle_signal(signum): try: sys.stderr.write("\n") sys.stderr.flush() cstr = "" if commandtype: cstr = commandtype + " " get_util_logger().info("%sgot signal %s", cstr, SIGNAMES.get(signum, signum)) except OSError: pass callback(signum) return True
def handle_signal(self, sig, frame): """ This is for OS signals SIGINT and SIGTERM """ #next time, just stop: signal.signal(signal.SIGINT, self.signal_stop) signal.signal(signal.SIGTERM, self.signal_stop) signame = SIGNAMES.get(sig, sig) try: log("handle_signal(%s, %s) calling stop from main thread", signame, frame) except: pass #may fail if we were doing IO logging when the signal was received self.send("signal", signame) self.timeout_add(0, self.cleanup) #give time for the network layer to send the signal message self.timeout_add(150, self.stop)
def register_os_signal(callback, commandtype="", signum=signal.SIGINT): from gi.repository import GLib #pylint: disable=import-outside-toplevel signame = SIGNAMES.get(signum, str(signum)) def write_signal(): if commandtype is None: return try: sys.stderr.write("\n") sys.stderr.flush() cstr = "" if commandtype: cstr = commandtype + " " get_util_logger().info("%sgot signal %s", cstr, signame) except OSError: pass def do_handle_signal(): callback(signum) if POSIX: #replace the previous definition if we had one: global _glib_unix_signals current = _glib_unix_signals.get(signum, None) if current: GLib.source_remove(current) def handle_signal(_signum): write_signal() do_handle_signal() return True source_id = GLib.unix_signal_add(GLib.PRIORITY_HIGH, signum, handle_signal, signum) _glib_unix_signals[signum] = source_id else: def os_signal(_signum, _frame): write_signal() GLib.idle_add(do_handle_signal) signal.signal(signum, os_signal)
def signal_stop(self, sig): """ This time we really want to exit without waiting """ signame = SIGNAMES.get(sig, sig) log("signal_stop(%s) calling stop", signame) self.stop()
def handle_signal(self, signum, frame=None): log("handle_signal(%s, %s)", SIGNAMES.get(signum, signum), frame) self.exit_code = 128-(signum or 0) GLib.idle_add(self.exit)
def app_signal(signum, frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit()
def handle_deadly_signal(self, signum, _frame=None): sys.stderr.write("\ngot deadly signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() self.cleanup() force_quit(128 + signum)
def deadly_signal(signum, frame): sys.stderr.write("\ngot deadly signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() self.cleanup() os._exit(128 + signum)
def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit()
def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True)
def deadly_signal(sig, frame): log.warn("got deadly signal %s", SIGNAMES.get(sig, sig)) gobject.idle_add(ss.stop) gobject.idle_add(gobject_mainloop.quit)
def signal_stop(self, sig, frame): """ This time we really want to exit without waiting """ signame = SIGNAMES.get(sig, sig) log("signal_stop(%s, %s) calling stop", signame, frame) self.stop()
def app_signal(signum, frame): sys.stderr.write("\ngot signal %s, exiting\n" % SIGNAMES.get(signum, signum)) sys.stderr.flush() signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) self.timeout_add(0, self.quit, 128 + signum)