def get_running_threads(self): """ Return a list of all running threads | **return** running_threads (seq of str) """ return thread_enumerate()
def downloads(self, page = 0): samples = [thread.name.split(' ')[1:] for thread in thread_enumerate() if thread.name.startswith('D')] samples += [[t, 0] for t in self.app.tasks.queue] samples += [[f.replace('.zip', ''), 100] for f in os.listdir(self.app.downloads) if f.endswith('.zip')] itemsperpage = self.app.config['itemsperpage'] return { 'samples': samples[itemsperpage * page : itemsperpage * (page + 1)], 'count': len(samples), 'maxpages': len(samples) // itemsperpage }
def init_sender_threads(): """Starts up an EventSenderThread to send events asynchronously""" #kill old threads. for thread in thread_enumerate(): if isinstance(thread, EventSenderThread): thread.stop() thread.join() est = EventSenderThread() est.start() return est
def _check_thread_status(): thread_names = ['keep alive'] for thrd in thread_enumerate(): if thrd.name.lower() in thread_names: thread_names.remove(thrd.name.lower()) for i in thread_names: if i == 'keep alive': msg = 'Keep Alive; Thread Crashed' log.error(msg) Thread(target=keep_alive, daemon=True, name='Keep Alive').start()
def get_kafka_consumer_group_desc(kcg_cmd, groups): kcg_threads = {} for group in groups: kcg_threads[group] = kcg_cmd.describe_t(group) log.debug("kcg java processes initiated - %d dispatch threads:\n%s" % (active_thread_count(), pformat(kcg_threads, indent=4))) kcg_desc = {} thread_timeout = 120 for group in groups: g_desc = kcg_threads[group].join(thread_timeout) if g_desc is not None: kcg_desc[group] = g_desc else: log.warning("kcg request '%s' joined empty" % group) if not (active_thread_count() == 1): log.warning("%d threads unreturned after timeout (%.2fs)" % ((active_thread_count()), thread_timeout)) log.debug("Active threads:\n%s" % pformat(thread_enumerate(), indent=4)) return kcg_desc