def get_thread_info(self, proto): #threads: info = {} info_threads = proto.get_threads() info["threads"] = threading.active_count() - len(info_threads) info["info_threads"] = len(info_threads) i = 0 #threads used by the "info" client: for t in info_threads: info["info_thread[%s]" % i] = t.name i += 1 i = 0 #all non-info threads: for t in threading.enumerate(): if t not in info_threads: info["thread[%s]" % i] = t.name i += 1 #platform specific bits: try: from xpra.platform.info import get_sys_info for k, v in get_sys_info().items(): info[k] = v except: log.error("error getting system info", exc_info=True) return info
def get_thread_info(proto=None): #threads: info_threads = proto.get_threads() info = { "count": threading.activeCount() - len(info_threads), "info.count": len(info_threads) } i = 0 #threads used by the "info" client: for t in info_threads: info["info[%s]" % i] = t.getName() i += 1 i = 0 #all non-info threads: for t in threading.enumerate(): if t not in info_threads: info[str(i)] = t.getName() i += 1 #platform specific bits: try: from xpra.platform.info import get_sys_info info.update(get_sys_info()) except: log.error("error getting system info", exc_info=True) return info
def get_thread_info(self, proto): #threads: info = {} info_threads = proto.get_threads() info["threads"] = threading.active_count() - len(info_threads) info["info_threads"] = len(info_threads) i = 0 #threads used by the "info" client: for t in info_threads: info["info_thread[%s]" % i] = t.name i += 1 i = 0 #all non-info threads: for t in threading.enumerate(): if t not in info_threads: info["thread[%s]" % i] = t.name i += 1 #platform specific bits: try: from xpra.platform.info import get_sys_info for k,v in get_sys_info().items(): info[k] = v except: log.error("error getting system info", exc_info=True) return info
def get_thread_info(proto=None): #threads: info_threads = proto.get_threads() info = { "count" : threading.activeCount() - len(info_threads), "info.count" : len(info_threads) } i = 0 #threads used by the "info" client: for t in info_threads: info["info[%s]" % i] = t.getName() i += 1 i = 0 #all non-info threads: for t in threading.enumerate(): if t not in info_threads: info[str(i)] = t.getName() i += 1 #platform specific bits: try: from xpra.platform.info import get_sys_info info.update(get_sys_info()) except: log.error("error getting system info", exc_info=True) return info
def get_thread_info(proto=None, protocols=[]): #threads: if proto: info_threads = proto.get_threads() else: info_threads = [] info = { "count" : threading.active_count() - len(info_threads), "info.count" : len(info_threads) } thread_ident = { threading.current_thread().ident : "info", main_thread.ident : "main", } w = get_worker(False) if w: thread_ident[w.ident] = "worker" it = info.setdefault("info", {}) #threads used by the "info" client: for i, t in enumerate(info_threads): it[i] = t.getName() thread_ident[t.ident] = t.getName() for p in protocols: try: threads = p.get_threads() for t in threads: thread_ident[t.ident] = t.getName() except: pass #all non-info threads: anit = info.setdefault("thread", {}) for i, t in enumerate((x for x in threading.enumerate() if x not in info_threads)): anit[i] = t.getName() #platform specific bits: try: from xpra.platform.info import get_sys_info info.update(get_sys_info()) except: log.error("error getting system info", exc_info=True) #extract frame info: try: def nn(x): if x is None: return "" return x frames = sys._current_frames() fi = info.setdefault("frame", {}) for i,frame_pair in enumerate(frames.items()): stack = traceback.extract_stack(frame_pair[1]) #sanitize stack to prevent None values (which cause encoding errors with the bencoder) sanestack = [] for e in stack: sanestack.append(tuple([nn(x) for x in e])) fi[i] = {"" : thread_ident.get(frame_pair[0], "unknown"), "stack" : sanestack} except Exception as e: log.error("failed to get frame info: %s", e) return info
def get_thread_info(proto=None, protocols=[]): #threads: info_threads = proto.get_threads() info = { "count": threading.active_count() - len(info_threads), "info.count": len(info_threads) } thread_ident = { threading.current_thread().ident: "info", main_thread.ident: "main", } w = get_worker(False) if w: thread_ident[w.ident] = "worker" #threads used by the "info" client: for i, t in enumerate(info_threads): info["info[%s]" % i] = t.getName() thread_ident[t.ident] = t.getName() for p in protocols: try: threads = p.get_threads() for t in threads: thread_ident[t.ident] = t.getName() except: pass #all non-info threads: for i, t in enumerate( (x for x in threading.enumerate() if x not in info_threads)): info[str(i)] = t.getName() #platform specific bits: try: from xpra.platform.info import get_sys_info info.update(get_sys_info()) except: log.error("error getting system info", exc_info=True) #extract frame info: try: def nn(x): if x is None: return "" return x import traceback frames = sys._current_frames() for i, frame_pair in enumerate(frames.items()): stack = traceback.extract_stack(frame_pair[1]) info["frame[%s].thread" % i] = thread_ident.get( frame_pair[0], "unknown") #sanitize stack to prevent None values (which cause encoding errors with the bencoder) sanestack = [] for e in stack: sanestack.append(tuple([nn(x) for x in e])) info["frame[%s].stack" % i] = sanestack except Exception as e: log.error("failed to get frame info: %s", e) return info
def get_info(self): info = { "pid" : os.getpid(), "threads" : get_frame_info(), "env" : get_info_env(), "sys" : get_sys_info(), "network" : get_net_info(), "logging" : get_log_info(), } if SYSCONFIG: info["sysconfig"] = get_sysconfig_info() for c in CLIENT_BASES: try: i = c.get_info(self) info = merge_dicts(info, i) except Exception: log.error("Error collection information from %s", c, exc_info=True) return info
def test_all_info(self): if POSIX: assert get_sys_info() assert isinstance(get_version_info(), dict) assert isinstance(get_user_info(), dict)