def __init__(self, app, daemon_action, callback, undo_callback, undo_outcome): self._app = app self._action = daemon_action self._undo_outcome = undo_outcome self._callback_mutex = Lock() self._callback_called = False self._callback_sync_sem = Semaphore(0) self._callback_outcome = None self._callback = callback self._undo_callback = undo_callback self._update_timer_elapsed = 0.0 self._update_timer_refresh = 0.5 self._update_timer = TimeScheduled(self._update_timer_refresh, self._update_countdown_wrapper) self._update_timer.set_delay_before(True) self._update_timer.daemon = True self._update_timer.name = "QueueActionNotificationBoxUpdateTimer" self._timer = Timer(self.TIMER_SECONDS + 1, self._callback_wrapper) self._action_label = Gtk.Label() self._action_label.set_line_wrap_mode(Pango.WrapMode.WORD) self._action_label.set_line_wrap(True) self._action_label.set_property("expand", True) self._action_label.set_alignment(0.02, 0.50) self._update_countdown(int(self.TIMER_SECONDS)) pkg = self._app.get_details().pkg context_id = "QueueActionNotificationContextId-%s" % (pkg, ) NotificationBox.__init__(self, None, message_widget=self._action_label, message_type=Gtk.MessageType.WARNING, context_id=context_id) self.add_button(_("Confirm"), self._on_confirm) self.add_button(_("Undo"), self._on_undo)
def _thread_dumper(self): """ If --dumper is in argv, a recurring thread dump function will be spawned every 30 seconds. """ dumper_enable = self._nsargs.dumper if dumper_enable: task = None def _dumper(): def _dump(): task.kill() dump_signal(None, None) timer = Timer(10.0, _dump) timer.name = "MainThreadHearthbeatCheck" timer.daemon = True timer.start() GLib.idle_add(timer.cancel) task = TimeScheduled(5.0, _dumper) task.name = "ThreadDumper" task.daemon = True task.start()