Example #1
0
    def cleanup(self):
        if self.terminate_children and self._upgrading != EXITING_CODE:
            self.terminate_children_processes()

        def noop():
            pass

        self.reaper_exit = noop
        reaper_cleanup()
        xmrt = self.xdg_menu_reload_timer
        if xmrt:
            self.xdg_menu_reload_timer = None
            self.source_remove(xmrt)
        wn = self.watch_notifier
        if wn:
            self.watch_notifier = None
            wn.stop()
        watch_manager = self.watch_manager
        if watch_manager:
            self.watch_manager = None
            try:
                watch_manager.close()
            except OSError:
                log("error closing watch manager %s",
                    watch_manager,
                    exc_info=True)
Example #2
0
 def cleanup(self):
     if self.terminate_children and self._upgrading!=EXITING_CODE:
         self.terminate_children_processes()
     def noop():
         pass
     self.reaper_exit = noop
     reaper_cleanup()
Example #3
0
 def cleanup(self):
     if self.terminate_children and self._upgrading!=EXITING_CODE:
         self.terminate_children_processes()
     def ignore():
         """ during cleanup, just ignore the reaper exit callback """
     self.reaper_exit = ignore
     if self.menu_provider:
         self.menu_provider.cleanup()
     reaper_cleanup()
Example #4
0
 def cleanup(self):
     reaper_cleanup()
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     self.cleanup_printing()
     log("cleanup done")
     dump_all_frames()
Example #5
0
 def cleanup(self):
     reaper_cleanup()
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     self.cleanup_printing()
     log("cleanup done")
     dump_all_frames()
Example #6
0
 def cleanup(self):
     reaper_cleanup()
     FilePrintMixin.cleanup(self)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     self.cancel_send_mouse_position_timer()
     dump_all_frames()
Example #7
0
 def cleanup(self):
     reaper_cleanup()
     #we must clean printing before FileTransferHandler, which turns the printing flag off!
     self.cleanup_printing()
     FileTransferHandler.cleanup(self)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     dump_all_frames()
Example #8
0
 def cleanup(self):
     reaper_cleanup()
     # we must clean printing before FileTransferHandler, which turns the printing flag off!
     self.cleanup_printing()
     FileTransferHandler.cleanup(self)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     dump_all_frames()
Example #9
0
    def test_sigchld(self):
        log.logger.setLevel(logging.ERROR)
        #one that exits before we add the process, one that takes longer:
        TEST_CHILDREN = (["echo"], ["sleep", "0.5"])
        count = 0
        for cmd in TEST_CHILDREN:
            cmd_info = " ".join(cmd)
            proc = subprocess.Popen(cmd)
            cr.add_process(proc, cmd_info, cmd_info, False, False, None)
            count += 1
            for _ in range(10):
                if not cr.check():
                    break
                time.sleep(0.1)
            #we can't check the returncode because it may not be set yet!
            #assert proc.poll() is not None, "%s process did not terminate?" % cmd_info
            assert cr.check(
            ) is False, "reaper did not notice that the '%s' process has terminated" % cmd_info
            i = cr.get_info()
            children = i.get("children").get("total")
            assert children == count, "expected %s children recorded, but got %s" % (
                count, children)

        #now check for the forget option:
        proc = subprocess.Popen(["sleep", "60"])
        cr.add_process(proc, "sleep 60", "sleep 60", False, True, None)
        count += 1
        assert cr.check() is True, "sleep process terminated too quickly"
        i = cr.get_info()
        children = i.get("children").get("total")
        assert children == count, "expected %s children recorded, but got %s" % (
            count, children)
        proc.terminate()
        #now wait for the sleep process to exit:
        for _ in range(10):
            if proc.poll() is not None:
                break
            time.sleep(0.1)
        assert proc.poll() is not None
        assert cr.check() is False, "sleep process did not terminate?"
        count -= 1
        i = cr.get_info()
        children = i.get("children").get("total")
        if children != count:
            raise Exception(
                "expected the sleep process to have been forgotten (%s children)"
                % count +
                "but got %s children instead in the reaper records" % children)
        reaper_cleanup()
Example #10
0
 def cleanup(self):
     reaper_cleanup()
     try:
         FilePrintMixin.cleanup(self)
     except Exception:
         log.error("%s", FilePrintMixin.cleanup, exc_info=True)
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     log("cleanup done")
     self.cancel_send_mouse_position_timer()
     dump_all_frames()
Example #11
0
 def cleanup(self):
     log("UIXpraClient.cleanup()")
     for c in CLIENT_BASES:
         c.cleanup(self)
     for x in (self.keyboard_helper, self.tray, self.menu_helper, self.client_extras):
         if x is None:
             continue
         log("UIXpraClient.cleanup() calling %s.cleanup()", type(x))
         try:
             x.cleanup()
         except Exception:
             log.error("error on %s cleanup", type(x), exc_info=True)
     #the protocol has been closed, it is now safe to close all the windows:
     #(cleaner and needed when we run embedded in the client launcher)
     reaper_cleanup()
     log("UIXpraClient.cleanup() done")
Example #12
0
 def cleanup(self):
     reaper_cleanup()
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     self.cleanup_printing()
     frames = sys._current_frames()
     log("after cleanup, found %s frames:", len(frames))
     for i, (fid, frame) in enumerate(frames.items()):
         log("%i: %s - %s:", i, fid, frame)
         for x in traceback.format_stack(frame):
             for l in x.splitlines():
                 log("%s", l)
Example #13
0
 def cleanup(self):
     reaper_cleanup()
     p = self._protocol
     log("XpraClientBase.cleanup() protocol=%s", p)
     if p:
         log("calling %s", p.close)
         p.close()
         self._protocol = None
     self.cleanup_printing()
     frames = sys._current_frames()
     log("after cleanup, found %s frames:", len(frames))
     for i,(fid,frame) in enumerate(frames.items()):
         log("%i: %s - %s:", i, fid, frame)
         for x in traceback.format_stack(frame):
             for l in x.splitlines():
                 log("%s", l)
Example #14
0
    def test_sigchld(self):
        import logging
        log.logger.setLevel(logging.ERROR)
        cr = getChildReaper()
        #one that exits before we add the process, one that takes longer:
        TEST_CHILDREN = (["echo"], ["sleep", "0.5"])
        count = 0
        for cmd in TEST_CHILDREN:
            cmd_info = " ".join(cmd)
            proc = subprocess.Popen(cmd)
            cr.add_process(proc, cmd_info, cmd_info, False, False, None)
            count += 1
            for _ in range(10):
                if not cr.check():
                    break
                time.sleep(0.1)
            #we can't check the returncode because it may not be set yet!
            #assert proc.poll() is not None, "%s process did not terminate?" % cmd_info
            assert cr.check() is False, "reaper did not notice that the '%s' process has terminated" % cmd_info
            i = cr.get_info()
            children = i.get("children").get("total")
            assert children==count, "expected %s children recorded, but got %s" % (count, children)

        #now check for the forget option:
        proc = subprocess.Popen(["sleep", "60"])
        cr.add_process(proc, "sleep 60", "sleep 60", False, True, None)
        count +=1
        assert cr.check() is True, "sleep process terminated too quickly"
        i = cr.get_info()
        children = i.get("children").get("total")
        assert children==count, "expected %s children recorded, but got %s" % (count, children)
        proc.terminate()
        #now wait for the sleep process to exit:
        for _ in range(10):
            if proc.poll() is not None:
                break
            time.sleep(0.1)
        assert proc.poll() is not None
        assert cr.check() is False, "sleep process did not terminate?"
        count -= 1
        i = cr.get_info()
        children = i.get("children").get("total")
        assert children==count, "expected the sleep process to have been forgotten (%s children), but got %s children instead in the reaper records" % (count, children)
        reaper_cleanup()
Example #15
0
    def do_test_child_reaper(self):
        #force reset singleton:
        child_reaper.singleton = None
        #no-op:
        reaper_cleanup()

        log.logger.setLevel(logging.ERROR)
        cr = getChildReaper()
        #one that exits before we add the process, one that takes longer:
        TEST_CHILDREN = (["echo"], ["sleep", "0.5"])
        count = 0
        for cmd in TEST_CHILDREN:
            cmd_info = " ".join(cmd)
            proc = subprocess.Popen(cmd)
            cr.add_process(proc, cmd_info, cmd_info, False, False, None)
            count += 1
            for _ in range(10):
                if not cr.check():
                    break
                time.sleep(0.1)
            #we can't check the returncode because it may not be set yet!
            #assert proc.poll() is not None, "%s process did not terminate?" % cmd_info
            assert cr.check() is False, "reaper did not notice that the '%s' process has terminated" % cmd_info
            i = cr.get_info()
            children = i.get("children").get("total")
            assert children==count, "expected %s children recorded, but got %s" % (count, children)

        #now check for the forget option:
        proc = subprocess.Popen(["sleep", "60"])
        procinfo = cr.add_process(proc, "sleep 60", "sleep 60", False, True, None)
        assert repr(procinfo)
        count +=1
        assert cr.check() is True, "sleep process terminated too quickly"
        i = cr.get_info()
        children = i.get("children").get("total")
        assert children==count, "expected %s children recorded, but got %s" % (count, children)
        #trying to claim it is dead when it is not:
        #(this will print some warnings)
        cr.add_dead_pid(proc.pid)
        proc.terminate()
        #now wait for the sleep process to exit:
        for _ in range(10):
            if proc.poll() is not None:
                break
            time.sleep(0.1)
        assert proc.poll() is not None
        assert cr.check() is False, "sleep process did not terminate?"
        count -= 1
        i = cr.get_info()
        children = i.get("children").get("total")
        if children!=count:
            raise Exception("expected the sleep process to have been forgotten (%s children)" % count +
            "but got %s children instead in the reaper records" % children)
        reaper_cleanup()
        #can run again:
        reaper_cleanup()
        #nothing for an invalid pid:
        assert cr.get_proc_info(-1) is None
Example #16
0
 def signal_cleanup(self):
     log("UIXpraClient.signal_cleanup()")
     XpraClientBase.signal_cleanup(self)
     reaper_cleanup()
     log("UIXpraClient.signal_cleanup() done")