Thread allready started ??

Thomas Weholt 2002 at
Tue Oct 1 20:37:36 CEST 2002

I'm trying to create a TaskManager, starting a bunch of threads on given
intervals. The problem is that I get an error "Thread allready started".
This TaskManager is running inside a threaded webserver, so I don't know if
this is the best way to have a set of tasks repeated over time on given
intervals. If anybody has any pointers I'd appreciate it.

Allready looking at recipies in the Python Cookbook, trying to hack one of
these into something like the code below, which is failing by the way.

NB! I want a Manager-thread starting/stopping sub-threads, not just a simple
while loop.

import threading, time

class TaskManager(threading.Thread):
    def __init__(self, tasks):
        self.tasks = tasks = 1
        self.wait = 5

    def run(self):
            for task in self.tasks:
                if task.doRun():

if __name__ == '__main__':

    class T(threading.Thread):

        def __init__(self):
   = 1

        def doRun(self):
            return 1

        def run(self):
            print "GO :%s" % self._Thread__name

    threads = []
    for i in range(0, 10):

    tm = TaskManager(threads)

    print "Main thread  is ", tm.isAlive()

More information about the Python-list mailing list