Hi I have a trivial application (see below). I expect it to print "Foo" on the first instance it is running and "Second" on each successive instance. Instead, only the first instance is printing stuff and the second doesn't do anything before it exits. Am I doing something wrong? Or did I run into a bug? import sys from gi.repository import Gio, GLib from _signal import SIGINT, SIGTERM, SIGHUP class TestApplication(Gio.Application): def __init__(self): Gio.Application.__init__( self, application_id="org.test", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) self.connect("activate", self.__on_activate) self.connect("command-line", TestApplication.__on_command_line) self.__main_loop = GLib.MainLoop.new(GLib.MainContext.default(), False) signals = [SIGINT, SIGTERM, SIGHUP] for signal in signals: GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal, self.__on_unix_signal) def __on_activate(self, app): self.__main_loop.run() def __on_unix_signal(self): self.__main_loop.quit() return GLib.SOURCE_REMOVE def __on_command_line(self, new_cli): Gio.ApplicationCommandLine.do_printerr_literal(new_cli, "foo\n") if new_cli.get_is_remote(): # second instance Gio.ApplicationCommandLine.do_print_literal(new_cli, "Second\n") return 0 # return status of second instance else: Gio.ApplicationCommandLine.do_print_literal(new_cli, "First\n") self.activate() return 0 # return status of first instance if __name__ == '__main__': sys.exit(TestApplication().run(sys.argv))
Attachment:
signature.asc
Description: This is a digitally signed message part