@@ -52,7 +52,6 @@ class Tasks(BaseCommand):
normal_threads = []
task_threads = []
task_thread_num = 0
for thread in threads:
tname = thread.name
@@ -62,25 +61,31 @@ class Tasks(BaseCommand):
elif tname in ["irc-frontend", "irc-watcher", "wiki-scheduler"]:
normal_threads.append("\x0302{}\x0301 (id {})".format(tname, thread.ident))
else:
task_thread_num += 1
task_threads.append("\x0302{}\x0301 (id {})".format(tname, thread.ident))
tname, start_time = re.findall("^(.*?) \((.*?)\)$")[0]
task_threads.append("\x0302{}\x0301 (id {}, spawned at {} )".format(tname, thread.ident, start_time ))
if task_threads:
msg = "\x02{}\x0F threads active: {}, and \x02{}\x0F task threads: {}.".format(len(threads), ', '.join(normal_threads), task_thread_num , ', '.join(task_threads))
msg = "\x02{}\x0F threads active: {}, and \x02{}\x0F task threads: {}.".format(len(threads), ', '.join(normal_threads), len(task_threads) , ', '.join(task_threads))
else:
msg = "\x02{}\x0F threads active: {}, and \x020\x0F task threads.".format(len(threads), ', '.join(normal_threads))
self.connection.reply(self.data, msg)
def do_listall(self):
tasks = task_manager.task_list.keys()
threads = map(lambda t: t.name, threading.enumerate())
threadlist = threading.enumerate()
threads = map(lambda t: t.name, threadlist)
tasklist = []
tasks.sort()
for task in tasks:
if task in threads:
tasklist.append("\x0302{}\x0301 (\x02active\x0F)".format(task))
threads_running_task = [t for t in threads if t.name.startswith(task)]
ids = map(lambda t: t.ident, threads_running_task)
if len(ids) == 1:
tasklist.append("\x0302{}\x0301 (\x02active\x0F as id {})".format(task, ids[0]))
else:
tasklist.append("\x0302{}\x0301 (\x02active\x0F as ids {})".format(task, ' ,'.join(ids)))
else:
tasklist.append("\x0302{}\x0301 (idle)".format(task))